< Pixel Backgrounds (download) | Styling Tables >
21 Nov 2006 > 0 Comments
Horizontal rules are used to divide content. But without styling, horizontal rules look pretty awful.
In HTML the Horizontal Rule has no closing tag.
<hr>
In XHTML the horizontal rule must be self-closing.
<hr />
Stying a Horizontal rule directly using CSS is a bit of a cross-browser problem, and a common workaround is to nest the <hr /> inside a <div> element, using the class attribute.
<div class="hr"><hr /></div>
In the Stylesheet, set the property and value as display: none; for the hr type selector. Although the Horizontal Rule is contained within the document it will only display when the Stylesheet is switched off.
Then, add a border to the div class selector .hr
hr {display: none;}
.hr {border-top: 1px solid #000000;}
And now the horizontal rule (or rather the <div> wrapper) displays as a line 1 pixel in height, which can be further styled using alternative border values.
< Back to everything
Keep going… >
Mahud Version 5 © 2006-2008 > powered by Mr Whippy Wordpress