Results 1 to 5 of 5

Thread: <hr> tag with CSS

  1. #1
    Join Date
    Oct 2005
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default <hr> tag with CSS

    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

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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:

    Code:
    .hr1 {
    height:4px;
    color:red;
    }
    
    .hr2 {
    width:70%;
    }
    Put the above in your stylesheet and use them in your document like so:

    HTML Code:
    <hr class="hr1">
    and:

    HTML Code:
    <hr class="hr2">
    You could use each of these as many times as required in the body of your page.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    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.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    What's next? Are they going to take the <p>?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Doubtful, but they might take my supply of commas if I keep abusing them like that.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •