Printed from TeacherJohn.com • http://teacherjohn.com/cabrillo/dm60a/exercises/ex09.php

Exercise 9: Tables


Resources for this exercise:


In this exercise you will create three different tables (counting the nested table as one table): a simple visible table, a simple invisible table, and one table nested within another table. I strongly recommend that you validate in stages, as many validation errors have to do with table structure. In other words, for each table: create the table with simple contents in its cells (say, a word or letter in each cell), upload the page, validate its structure, fix errors, then add the real contents. In the case of the nested table, create the two tables separately, validate them, and then you can simply paste one table into a cell of the other.

Place a horizontal rule between the three tables (this means you must use two <hr> tags).

Step 1 - Create your exercise 9 page

1.1) Using a basic text editor create an HTML document. This page will become your exercise 9 page.

1.2) This page must display your name and "Exercise 9".

1.3) This page's <title> must indicate that this is your exercise 9, so it should say something like "John Sky's DM60 Exercise 9".

1.4) This page must contain the HTML 5 DocType that will enable you to use an HTML validator, as explained in How to Use the W3C HTML and CSS Validators.

1.5) This page must contain the character encoding meta tag (as explained in Character Encoding for Web Pages). Because this tag tells the browser how to interpret the characters used in the document, it should be the first tag in the <head> section. So right after the <head> tag, place this line of code:

<meta charset="utf-8">

1.6) This page must contain links (either buttons or text links) to the HTML and CSS validators. See How to Put HTML and CSS Validate Buttons on Your Page for information on how I want you to to do this. Make sure you use the code for HTML 5 (not XHTML 1.0 Strict nor HTML 4, for example). (Use the block of code on this page to make the button links or text links, so that clicking on the links automatically lets you know if the page validates or not.)

Make sure you use the correct links (for HTML 5).

1.7) This page must contain a link with a relative path to your home ("index.html") page (this path will not start with "http://", as it must be a relative path, not a URL).

1.8) This page must contain a visible table with at least 3 rows and 3 columns (to make the table structure visible, set the value of the CSS border property applied to <table> to something other than zero). Place some text in every cell.

1.9) This page must contain a another, different table with at least 3 rows and 3 columns, but this table must be invisible (to do this, set the value of the CSS border-style property applied to table to none). Do not use any background colors in this table (it's supposed to be an invisible table, OK?). Place text in every cell.

1.10) This page must contain a table nested within another table. Both of these tables must have at least 2 rows and 2 columns, and both must be visible. Place text in every cell. These tables must be separate from, and different from, the other two tables.

Hint: remember that a nested table is a complete table inserted into a table cell of another table (just as a nested list is a complete list inserted into a list item of another list). The best way to proceed is to create these two tables separately, and then simply cut and paste one table into a cell (in other words, between a <td> and </td>) of the other table.

1.11) Place a horizontal rule between each table.

1.12) This page must demonstrate the use of the <caption> element.

1.13) Demonstrate the use of all the elements listed below in these tables. (Each table does not have to use all of these elements, but each of these tags must be demonstrated somewhere on the page.)

1.14) In summary, this page must correctly use the following HTML elements:

Description Element
headline h1
horizontal rule hr
table <table>
table row <tr>
table header <th>
table data cell <td>
table caption <caption>

Note that, for the next two steps, you may use either external, internal, or local styling. If you use an external style sheet, of course, you will need to create and save the style sheet and upload it to your css folder on the server.

1.15) Using CSS, make a color appear as the background of at least two table cells (use the background-color property). Use a different color for each table cell.

1.16) Using CSS, make the contents of a <td> (not a <th>) align centered horizontally.

1.17) Save this file as "exercise9.html".

1.18) Upload this page to your "public_html" folder on the webhawks.org server.

1.19) View your page (the page on the server, not the page on your disk) in a Web browser:

Go to:
http://www.webhawks.org/~yourusername/exercise8.html
to view your exercise 9 page.

1.20) Make sure the HTML on this page validates (using the HTML 5 Doctype) with no errors, according to the W3C's online HTML Validator at http://validator.w3.org/. You can easily do this by clicking on your HTML validator link. For more information, see How to Use the W3C HTML and CSS Validators for step-by-step directions.

1.21) Make sure the CSS on this page validates, with no errors, according to the W3C's online CSS Validator at: http://jigsaw.w3.org/css-validator/. You can easily do this by clicking on your CSS validator button. See the CSS section of How to Use the W3C HTML and CSS Validators for step-by-step directions.

1.22) If there are any errors, fix them, re-upload the page, and validate it again.

Step 2 - Modify your home page

2.1) Modify your home page to include a link that goes to your exercise 9 page. Make sure your home page has a working link to each of your completed exercises, and that these links are coded as an HTML list.

2.2) As always, your home page must contain links (either buttons or text links) to the HTML and CSS validators. See How to Put HTML and CSS Validate Buttons on Your Page for information on how I want you to to do this. Make sure you use the code for HTML 5 (not XHTML 1.0 Strict nor HTML 4, for example). (Use the block of code on this page to make the button links or text links, so that clicking on the links automatically lets you know if the page validates or not.)

2.3) Make sure the HTML on this page validates (using the HTML 5 Doctype) with no errors, according to the W3C's online HTML Validator at http://validator.w3.org/. You can easily do this by clicking on your HTML validator link. For more information, see How to Use the W3C HTML and CSS Validators for step-by-step directions.

2.4) Make sure the CSS on this page validates, with no errors, according to the W3C's online CSS Validator at: http://jigsaw.w3.org/css-validator/. You can easily do this by clicking on your CSS validator button. See the CSS section of How to Use the W3C HTML and CSS Validators for step-by-step directions.

2.5) View your home page (the page on the server, not the page on your local disk) in a Web browser to make sure your links work.

2.6) If there are any errors, fix them, re-upload the page, and validate it again.

Step 3 - Submit the feedback form

3.1) Submit the feedback form. To receive fll credit for this exercise you must submit this feedback form before it expires. This exercise is due on 4/10/17. Allowing for a one-day grace period, the form will expire at the end of the day following the due date, which means the form for this exercise will expire at 12:00 AM on 4/12/17.


Optional Fun

Note that, in this exercise, I do not require you to demonstrate the use of the rowspan or colspan attributes of <td>. After you have a good understanding of basic table structure, you may wish to try modifying the structure of a table with rowspan or colspan. This would be a good thing to try, but only if you are comfortable building a basic table with no validation errors. If you wish to try this, I ask that you leave the rest of your exercise page the way it is, and add another table to play with these attributes. And if you can't get it to validate, you should remove it (so you don't lose credit for validation errors) and place it on a different page for troubleshooting.