|
Looking at this table, you must admit that it doesn't look very nice. All of the columns have different widths. Numbers are all aligned left, but numbers in a table usually look better when they are aligned right. The years in the left column are actually row headers, but look the same as the rest of the table data. The border lines are a bit too heavy. Also, the title (caption) of the table does not stand out as it should. Let's see what we can do improve the appearance of this table. Practice:OK, open your source file in your text editor and lets make a few changes. Save and view your table after each change in order to see how each setting affects the appearance of the table. First of all, let's make the caption bold. Add a pair of B tags to the caption.Next, let's use the ALIGN attribute to make the numbers align to the right edges of the cells. If no ALIGN attribute is set, header cell TH data is centered, but text or numbers in TD cells will be aligned left. We want to keep the header data centered, but want the numbers below aligned right. We could add the align attribute to the TD tag of every cell, but it is easier and faster to apply it to the row tags. Add an align="right" attribute to each row tag except for the header row. The columns would look better if they were all the same width. Let's use the WIDTH attribute to standardize column width. Column width can be set either in pixels, or as a percentage of the width of the screen. You can experiment with percentages at another time. For now, let's set each column to the same width in pixels. Again, we could set the width of each cell, but all we really need to do is set the width of each cell in the header row or first row of the table. Add a width="70" attribute to each cell in the header row. Next, let's adjust the thicknesses of the table lines. First, let's make the outer border of the table thicker. Change the value of the border attribute of the TABLE tag from "1" to "3". Then, let's make the lines inside the table a bit thinner by changing the value of the cellspacing attribute of the TABLE tag from "2" to "1". The space around the text in each cell can be changed by increasing or decreasing the cellpadding value. Cellpadding is the space, in pixels, between the text in each cell and the cell lines. Change the cellpadding value of the table tag from "2" to "4". Let's also change the background colors to make the table easier to read. First, set the background color of the entire table to light gray. Add the bgcolor="#f5f5f5" attribute to the table tag. Then, change the color of the header row to teal blue. Add bgcolor="#99cccc" to the first table row tr tag. To finish up, color the cells in the first column a light blue by adding bgcolor="#ccffff" to each of the table data td tags in the first column. Finally, let's center the entire table on the page with a DIV align="center" tag. .
After making all of the above changes, your table should look like the table below: And, your practice file should look like this.
The table now looks much better than it did at the beginning of this lesson. However, there are still a few more changes to make before we are completely finished. When you are ready, go on to the final lesson on tables. Review:
|
|
|
|
|