www.webdeveloper.com
Results 1 to 4 of 4

Thread: Turning HR into DIV

  1. #1
    Join Date
    Aug 2006
    Posts
    89

    resolved Turning HR into DIV

    Can I make a <DIV> tag emulate a <HR>? Or somehow use CSS to do this?
    Last edited by meinsla; 09-07-2006 at 04:14 PM.

  2. #2
    Join Date
    Dec 2005
    Location
    American, living in Toronto, ON. CANADA
    Posts
    6,746
    Something like:

    <div style="width:95%; height:4px; margin:10px auto 10px auto; border-top:2px solid gray;"></div>

    An empty DIV that 4-px in height, 95% of the screen-width wide so that it re-sizes nicely, 2-px thick solid gray line, and a 10-px top & bottom margin.

    If you plan to use it several times in the same web site, you could roll all that CSS into a "class" and call it ".hr", so your DIV for the default horizontal rule would look like:

    <div class="hr"></div>
    and it does exactly the same thing.

  3. #3
    Join Date
    Jan 2005
    Location
    Frankfort, KY, USA
    Posts
    6,167
    (But if you're striving for pure semantic mark-up, you might use a border-bottom setting for section container divs.)
    CSS
    Code:
    .section-content {border-bottom: 1px solid #000; margin-top: 1em; margin-bottom: 1em;}
    HTML
    Code:
    <div class="section-content">
    <p>text text text</p>
    </div>
    <div class="section-content">
    <p>more text text text</p>
    </div>

  4. #4
    Join Date
    Aug 2006
    Posts
    89
    Thanks a lot for your help.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles