Making Sure Your Borders Show Up .........................................................
Here’s a common head CSS programming head-scratcher:
p {border: 12px;}
In spite of this rule that you wrote, no border shows up around the paragraphs.
You’d logically think that by specifying a border size, you’d see a border. Not
so. Unless you also specify a border style, you don’t get a border. The default
style is none,so change it to include a style:
p {border: solid 12px;}
Watching Out for Color Clash ....................................................................
What if you specify a text color, but fail to specify a background color? Sounds
harmless, but it can be a problem. Some users employ personal style sheets,
including their favorite colors. What happens if a user specifies brown for their
backgrounds and white for their text? Say that you specify brown for your text:
BODY {color: brown;}
The user won’t see your text at all because their background color and your
foreground (text) color are identical. The solution? Alwaysspecify a back-
ground if you’re going to color the text. Then you have control over how the
text looks against that background:
BODY {color: brown; background-color: yellow;}
Centering for Everyone ..............................................................................
Centering elements on a Web page still isn’t quite solved. It’s a common
enough task — you want some things centered on the page, such as certain
kinds of titles and headlines. But how to do it?
One method is to put an element inside a div, and then center the div
(this works in Netscape or Mozilla or Firefox and so on, but not in Internet
Explorer). Setting a div’s margin to zeroand auto, you effectively center it
in all browsers except IE:
320 Part V: The Part of Tens