Web Development HTML Guide - Learn HTML
Developer Tutorials
ASP
CGI & Perl
CSS
Flash
HTML
Java
JavaScript
Linux
MySQL
PHP
Photoshop
Python
Wireless
XML



Developer Manuals
Learn HTML
Learn PHP
Learn MySQL
Learn CSS
Learn Pear


Developer Scripts
ASP Scripts
ASP.NET Scripts
CGI & Perl Scripts
Flash Scripts
Java Scripts
JavaScript Scripts
PHP Scripts
Python Scripts
Remotely Hosted Scripts
Tools & Utilities Scripts
XML Scripts

Developer Resources
Developer Tools
Developer News
Developer Forums
Developer Content
Developer Book Reviews
Survey Software

Web Hosting Directory
Budget Web Hosting
ColdFusion Hosting
Dedicated Servers
Domain Hosting
E-Commerce Hosting
Email Hosting
Free Web Hosting
Linux Web Hosting
Managed Hosting
Reseller Hosting
Small Business Hosting
Windows Web Hosting

Fonts in Tables

Of special interest to webmasters who do a lot of tables is the application of styles to tables. If you've ever attempted to use the <FONT ...> tag in conjunction with tables you know how painful it can be. You have to put a complete <FONT ...> tag inside every table cell, resulting in mountains of difficult-to-edit code. Perhaps you've written painful code like this:

<TABLE BORDER BGCOLOR=NAVY>
<TR> <TH><FONT COLOR=WHITE FACE="Geneva, Arial" SIZE=6>fruit</FONT></TH> <TH><FONT COLOR=WHITE FACE="Geneva, Arial" SIZE=6>state</FONT></TH> </TR>
<TR> <TD><FONT COLOR=WHITE FACE="Geneva, Arial" SIZE=6>apples</FONT></TD> <TD><FONT COLOR=WHITE FACE="Geneva, Arial" SIZE=6>Washington</FONT></TD> </TR>
<TR> <TD><FONT COLOR=WHITE FACE="Geneva, Arial" SIZE=6>pineapples</FONT></TD> <TD><FONT COLOR=WHITE FACE="Geneva, Arial" SIZE=6>Hawaii</FONT></TD> </TR>
</TABLE>

If you're in this situation, styles will make your life simpler.

Let's look at an example. The following styles code (in a STYLE tag or in a style sheet file) creates a rule that applies to elements of the boldtable class, and also to <TD ...> and <TH ...> elements inside the boldtable class:

.boldtable, .boldtable TD, .boldtable TH
{
font-family:sans-serif;
font-size:20pt;
color:white;
background-color:navy;
}

We can apply this style to an entire table by simply setting the class of the table to boldtable:

<TABLE BORDER CLASS="boldtable">
<TR> <TH>fruit</TH> <TH>state</TH> </TR>
<TR> <TD>apples</TD> <TD>Washington</TD> </TR>
<TR> <TD>pineapples</TD> <TD>Hawaii</TD> </TR>
</TABLE>

which gives us this table:

fruit state
apples Washington
pineapples Hawaii

The keen observer will notice that there's some redundancy in the selector. After all, if we set the entire table to the boldtable class, then it should automatically apply to the <TD ...> and <TH ...> elements inside. That's how it should work, but that's where reality rears its ugly head. Netscape has a bug such that it doesn't understand that the contents of table cells get the font styles applied to the table as a whole. However, it is able to apply the styles if <TD ...> and <TH ...> are mentioned explicitly.


Copyright Idocs, Inc. Written by Miko Sullivan











About the NetVisits, Inc Network | Advertise
Developer Tutorials hosted by HostGator.
Copyright ©2007 NetVisits, Inc Network. All Rights Reserved. Privacy Policy.
Visit other NetVisits, Inc. sites: