Styling the horizontal rule

It’s never good practice to use HTML elements as presentation elements, but sometimes you gotta use an <hr />.

color: #000;
background-color: #000;
height: 4px;
border: none;

Note that you have to specify the color and background color so it works in IE.

5 Comments

  1. Posted July 29, 2008 at 1:15 pm | Permalink

    I don’t use hr’s at all. Haven’t for years. I just use a border and bump up the margin or padding, or in rare cases, an empty div with a border.

  2. Posted July 30, 2008 at 11:45 am | Permalink

    Ah thanks, I was wondering why my HRs weren’t working right in IE on PB.

  3. Posted August 14, 2008 at 11:12 am | Permalink

    I’m with Todd, I haven’t used hr tags in a long time, but this is good to know in case I do ever need it.

    Any chance of some new tips being posted soon? :)

  4. Posted August 17, 2008 at 11:31 am | Permalink

    well what about mozilla. how will it look i mozilla?

  5. Posted August 25, 2008 at 3:45 am | Permalink

    The problem here is if you want a 1px high hr. It will not work in all browsers, no matter what you do.

    And you should probably use hr-s where you want to separate sections with it. hr-s are not meant for presentation only, they also show up as separators for blind people or people with other visual accessibility problems.

3 Trackbacks

  1. By Style the horizontal rule | CLD Tutorials on July 28, 2008 at 3:58 am

    […] : cssforlunch.com Difficulty : […]

  2. By Style the horizontal rule | CLD Tutorials on July 28, 2008 at 4:15 am

    […] Source : cssforlunch.com […]

  3. By irhfyjhx on October 14, 2008 at 12:19 am

    irhfyjhx…

    irhfyjhx…

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*
vpn service