PDA

View Full Version : <hr> tag with CSS



Max_Current
07-27-2006, 10:16 PM
Hi guys,

How would I define different break/hr styles in CSS and then call them all in various places in my HTML file?

Thanks,

Max

jscheuer1
07-27-2006, 10:47 PM
Well, aside from the fact that the <hr> element is one of the less consistent across browsers (at least it tends to look OK in all of them), you would do it just the same as for any other element. That is to define several classes (as many as you need) for them or to select them in other ways (let's not worry about that now). So, you could have, say you need two kinds:


.hr1 {
height:4px;
color:red;
}

.hr2 {
width:70%;
}

Put the above in your stylesheet and use them in your document like so:


<hr class="hr1">

and:


<hr class="hr2">

You could use each of these as many times as required in the body of your page.

Twey
07-27-2006, 11:20 PM
It should be noted, however, that use of the <hr> tag, as with <br>, is, while still valid, discouraged, as it is no longer necessary; a border should be used instead.

jscheuer1
07-28-2006, 04:13 AM
What's next? Are they going to take the <p>?

Twey
07-28-2006, 09:38 AM
Doubtful, but they might take my supply of commas if I keep abusing them like that. :p