Table Fonts and ColorsThis is the last of four pages detailing tables. Up until now, all the tables we have created have been black and white. You have been introduced to many different attributes and nearly endless possibilities, but the time has come to make the list of choices even longer. Note that some browsers handle fonts and colors in different ways. These differences will be noted in each section. Changing the Fonts (The Font-Face Shuffle)This is the first area where Netsacpe and Internet Explorer clash. (Right off the bat, go figure).
If you are using Netscape, the following table will look notably different from the others so far:
In the above table, I specified <font face="Playbill" size="5"> for every cell. In the next example, however, I have specified the same font change using a single statement outside of the table tags. There is one noticable difference for users of each browser. Internet Explorer users will see the playbill font face, but the size will be default for the page; size changes must be specified for every cell. Netscape users, however, will be seeing their default font face AND size.
Perhaps you can see the difference, perhaps you can't. It all depends on what browser you are using. Even if you have a font specified for your page, it might be a good idea to take a few extra minutes to add the font changes to individual cells. This assures that everyone can enjoy the different fonts. You can also change the font face, size and color to something different from the rest of your page, but remember that your guests will only be able to see a font if they have it installed on their computer. | ||||||||||||||||||||||||||||||||||||||||||||||||||
Table ColorTime for a few more attributes. By adding bgcolor="#xxxxxx" to the <table> tag you can modify the background color of the entire table.
Some older browsers, particularly older versions of Netscape, do not support this attribute at all and will only display the same background as the rest of the page. <table bgcolor="#191970" border="6" align=center width="50%" cellpadding="2">
Coloring Idvividual CellsThe bgcolor attribute can also be added to the <td> and <th> of individual cells. Just like table background, however, some older browsers do not support this feature. <td bgcolor="#057500">
Border ColorIt is also possible to change the color of a table's border. This can be incredibly useful for calling attention to data inside a table. To do this, add border color="#xxxxxx" to the <table> tag. <table bgcolor="#ffffff" bordercolor="#000000" border="6" align=center width="50%" cellpadding="2">
The Two-Tone Paint JobThis is a pair of attributes that can be used to give your tables a border with two different colors. Take a look at the border of a default table. Notice that it has a light portion and a dark portion? These can be modified individually using bordercolorlight and bordercolordark. However, there is a catch:
<table bgcolor="#000000" bordercolorlight="#aaaaaa" bordercolordark="#9036d0" border="6" align=center width="50%" cellpadding="2">
A Few Notes About Empty CellsIn previous sections I mentioned making cells with no data in them, or "empty cells". Currently, the only browser that does a good job of handling empty cells is IE 5.0; however there is still hope for older browsers. A little tiny (invisible) GIF file can help a lot.
Here's a table to show you what I mean:
Alternately, if you don't want to worry about using the single-pixel .gif file, you can type between the <td> and </td> tags. This tells the browser to put a space in the cell (just like the space bar on your keyboard). Nothing will show up in the cell, but the browser will THINK that there is somthing there. Would you like your own invisible GIF file to place in enmpty cells? Right click in the table cell below and save the file to your disk. Enjoy!!
Adding Background ImagesThis feature allows you to put a separate background image in a table. This can have a nice effect on a lot of pages, and can make your work look very profesional (wether it actually is or not). Unfortunately, this feature is not very widely supported (yet...) and many browsers won't recognize it. I use Internet Explorer 5.0, and I know that it does, but I cannot speak for all others out there. I will, however, pass along whatever I learn. To add a background image, type background="filename" along with any other attributes of your <table> tag.
<table border="14" cellpadding="20" background="space1.gif">
If you specify a background color for one or more cells in a table with a background image, different browsers treat the image differently.
Background Images for Single CellsAs with table background images, this feature is not widely supported. I am fairly certain that any browser which supports table background images supports cell background images as well, but I don't know for sure. To put a background image in a cell instead of the whole table, add the background="filename" attribute to the <td> or <th> tag. <td background="bluesatin.jpg">
Closing ThoughtsWell...We've covered a lot of miles; tables are a gigantic subject. Hopefully you haven't suffered a nervous breakdown by now, and I certainly hope I haven't run you out of printer ink. The stuff can get expensive. Enjoy. |
||||||||||||||||||||||||||||||||||||||||||||||||||