HTML and CSS Reference
In-Depth Information
NOTE
The nowrap attribute has been deprecated in HTML 4.01 in favor
of using style sheet properties.
To achieve the same results in CSS, use the white-space property. The default value is
“normal” . To disable word wrapping, use the value “nowrap” . Here's how one of the
headings in the previous example would be written using CSS:
<th style=”white-space: normal”> Batting Average </th>
Be careful when you hard-code table cells with line breaks and nowrap attributes.
Remember, your table might be viewed by users with many different screen widths. Try
resizing the browser window to make sure your table still looks correct. For the most
part, try to let the browser format your table and make minor adjustments only when
necessary.
Table and Cell Color
After you have your basic table layout with rows, headings, and data, you can start refin-
ing how that table looks. You can refine tables in a couple of ways. One way is to add
color to borders and cells.
There are two ways to change the background color of a table, a row, or a cell inside a
row. In the pre-CSS world, you would use the bgcolor attribute of the <table> , <tr> ,
<th> , or <td> elements. Just as in the <body> tag, the value of bgcolor is a color speci-
fied as a hexadecimal triplet or one of the 16 color names: Black, White, Green, Maroon,
Olive, Navy, Purple, Gray, Red, Yellow, Blue, Teal, Lime, Aqua, Fuchsia, or Silver. In
the style sheet world, you use the background-color property or the background prop-
erty. You can use the style attribute in the <table> , <tr> , <th> , and <td> elements, just
as you can in most other elements. Each background color overrides the background
color of its enclosing element. For example, a table background overrides the page back-
ground, a row background overrides the table's, and any cell colors override all other col-
ors. If you nest tables inside cells, that nested table has the background color of the cell
that encloses it.
Also, if you change the color of a cell, don't forget to change the color of the text inside
it so that you can still read it.
 
 
Search WWH ::




Custom Search