horizontal line and right way to code it in html, css

前端 未结 10 997
借酒劲吻你
借酒劲吻你 2020-12-04 08:12

I need to draw a horizontal line after some block, and I have three ways to do it:

1) Define a class h_line and add css features to it, like

<         


        
相关标签:
10条回答
  • 2020-12-04 08:56

    it is depends on requirement , but many developers suggestions is to make your code as simple as possible . so, go with simple "hr" tag and CSS code for that.

    0 讨论(0)
  • 2020-12-04 09:05

    In HTML5, the <hr> tag defines a thematic break. In HTML 4.01, the <hr> tag represents a horizontal rule.

    http://www.w3schools.com/tags/tag_hr.asp

    So after definition, I would prefer <hr>

    0 讨论(0)
  • 2020-12-04 09:09

    hr {
        display: block;
        height: 1px;
        border: 0;
        border-top: 1px solid #ccc;
        margin: 1em 0;
        padding: 0;
    }
    <div>Hello</div>
    <hr/>
    <div>World</div>

    Here is how html5boilerplate does it:

    hr {
        display: block;
        height: 1px;
        border: 0;
        border-top: 1px solid #ccc;
        margin: 1em 0;
        padding: 0;
    }
    
    0 讨论(0)
  • 2020-12-04 09:09

    I'd go for semantic markup, use an <hr/>.

    Unless it's just a border what you want, then you can use a combination of padding, border and margin, to get the desired bound.

    0 讨论(0)
提交回复
热议问题