brucie said:
browsers vary on how they apply styles to a <hr>. e.g. opera doesn't
need 'color:red' but other browsers do or some don't need
'background:red'. the solution i provided for the OP gives the most
consistent styling across browsers.
We might even say that there is nothing that says that either color or
background-color has any effect on rendering. That is, what is content
(in the CSS sense) and what is background for a horizontal line?
So while the technique currently works on most (or all?) graphic
browsers, you can't really complain if a browser vendor chooses to
implement <hr>, by default, as border around some empty content.
This in turn suggests that it's better to use a bottom border for a
preceding element, or a top border for the next element. In that case you
would not use any HTML element like <hr> but instead make sure that the
preceding or next element is a block element, e.g.
<div style="border-bottom: solid red 1px">
stuff preceding the line
</div>
stuff after the line
This gives the extra option of using other border formatting, e.g.
creating a dashed or outset border.
On the other hand, if the line is meant to work as a separator between
topics, or something, I would use
<div style="border-bottom: solid red 1px">
stuff preceding the line
<hr style="display:none">
</div>
stuff after the line
to create a fallback for non-CSS browsing.