Chapter 54. Rehabilitating Horizontal Rules
One of the most useful but least used elements in all HTML is the humble horizontal rule. Its goal is a simple but noble one: to create a visual dividing line between the sections of a page.The best thing about this element is that it's a free graphic. The browser generates it internally. Your visitors don't have to download it, which reduces the overall graphics load and improves the performance of your site.Part of the problem with the horizontal rule is that, out of the box, it's too long, too blocky, and too obtrusive, as Figure 54.1 shows. Most designers would rather separate the sections of their page with elegant whitespace, not this ugly thing. But if you take the time to adjust its attributes, you can create some truly classy effects, as in Figure 54.2.
Figure 54.1. Unmodified, HTML's horizontal rule is an aesthetic train wreck.
[View full size image]

Figure 54.2. With a little attribute modification, the horizontal rule shows promise.
[View full size image]

ATTRIBUTE | CONTROLS | POSSIBLE VALUES | EXAMPLES |
---|---|---|---|
align | The horizontal position of the element | left, right, center | <hr align="left"> <hr align="center"> |
noshade | That the horizontal rule doesn't appear with a 3D shading effect | No value | <hr noshade> |
size | The height of the element in pixels | Any numeric | <hr size="10"> |
width | The horizontal size of the element in pixels | Any numeric, including percentages | <hr width="50"> <hr width="33%"> |
The noshade attribute doesn't take a value. It either appears in the hr tag, or it doesn't.Next, to make the horizontal rule subtler, reduce its height. By default, the rule is 2 pixels tall in Internet Explorer and 3 pixels tall in Netscape. Setting the size attribute to 1 not only standardizes the appearance of the element across browsers, it improves its effectiveness. Slimmer is better; you don't want the horizontal rule calling too much attention to itself. So:
<hr noshade>
The standard horizontal rule is also too long. By default, it fills the entire width of the page or whatever container element it happens to be in, such as a table cell or a CSS div. Truncated horizontal rules work better. They introduce extra whitespace into your design, which helps your layout to breathe.Some designers prefer to give precise pixel measurements for the width of the horizontal rule, like this:
<hr noshade size="1">
<hr noshade size="1" width="200">
TIPYou may alter the color of horizontal rules with CSS, but browsers don't agree on which CSS attribute is the right one for the job. Internet Explorer prefers the color attribute, while Netscape insists on background-color. Setting the color attribute in Netscape does nothing in IE. Similarly, setting the background color in IE does nothing in Netscape.One possible workaround is to specify both attributes in your style definition:
|
<hr noshade size="1" width="20%">
TIPAnother classy effect is to set the height of a horizontal rule to some modest amount, like 4 or 5 pixels, and remove the noshade attribute. Doing this creates a hollow, rectangular box. |
<hr noshade size="1" width="20%" align="left">
GEEKSPEAKAn end sign is a bullet or typographical character that appears at the end of a story or article. It is also a prophecy that Armageddon is nigh. |