Workshop


Today's lesson covered one of the more complex subjects in HTMLtables. Before you move on to full immersion into the world of Cascading Style Sheets, you should work through the following questions and exercises to make sure that you've really got a good grasp of how tables work.

Q&A

Q

Tables are a real hassle to lay out, especially when you get into row and column spans. That last example was awful.

A

You're right. Tables are a tremendous pain to lay out by hand like this. However, if you're using writing editors and tools to generate HTML code, having the table defined like this makes more sense because you can just write out each row in turn programmatically.

Q

Can you nest tables, putting a table inside a single table cell?

A

Sure! As I mentioned earlier, you can put any HTML code you want inside a table cell, and that includes other tables.

Q

Why does most of the world use align for positioning a caption at the top or bottom of a page, but Internet Explorer does something totally different?

A

I don't know. And worse, Microsoft claims it got that definition for Internet Explorer from HTML 3.0, but no version of HTML 3.0 or the tables specification in HTML 3.2 has it defined in that way. HTML 4.01 added left and right aligning to this attribute, but Internet Explorer added that alignment before HTML even mentioned the possibility.

Quiz

1.

What are the basic parts of a table, and which tags identify them?

2.

Which attribute is the most common attribute of the table tag, and what does it do?

3.

What attributes define the amount of space between the edges of the cells and their content, and the amount of space between cells?

4.

Which attributes are used to create cells that span more than one column or row?

5.

Which elements are used to define the head, body, and foot of a table?

Quiz Answers

1.

The basic parts of a table (the <table> tag) are the border (defined with the border attribute), the caption (defined with the <caption> tag), header cells (<th>), data cells (<td>), and table rows (<tr>).

2.

The border attribute is the most common attribute for the table tag. It specifies whether border lines are displayed around the table, and how wide the borders should be.

3.

cellpadding defines the amount of space between the edges of the cell and their contents. cellspacing defines the amount of space between the cells.

4.

The rowspan attribute creates a cell that spans multiple rows. The colspan attribute creates a cell that spans multiple columns.

5.

<thead>, <tbody>, and <tfoot> define the head, body, and foot of a table.

Exercises

1.

Here's a brainteaser for you: Create a simple nested table (a table within a table) that contains three rows and four columns. Inside the cell that appears at the second column in the second row, create a second table that contains two rows and two columns.

2.

Modify the table shown in Figure 8.30 so that the rules in the table only appear between columns.




Sams Teach Yourself Web Publishing with HTML and CSS in One Hour a Day
Sams Teach Yourself Web Publishing with HTML and CSS in One Hour a Day (5th Edition)
ISBN: 0672328860
EAN: 2147483647
Year: 2007
Pages: 305

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net