Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

html

css

People also ask

How do I draw a horizontal line in HTML CSS?

Adding the Horizontal Line using <hr> tag: The Horizontal Rule tag (<hr>) is used for the purpose of inserting horizontal lines in the HTML document in order to separate sections of the document. It is an empty or unpaired tag that means there is no need for the closing tag.

How do you code horizontally in HTML?

HTML <hr> Tag. The <hr> tag in HTML stands for horizontal rule and is used to insert a horizontal rule or a thematic break in an HTML page to divide or separate document sections. The <hr> tag is an empty tag, and it does not require an end tag.

How do I add a horizontal line to my website in HTML?

Using the <hr> tag, we can divide document sections. The <hr> tag is an empty tag. It means that it does not require an end tag. So, you need to type <hr> to add a horizontal line to an HTML page.


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;
}

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.


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>


If you really want a thematic break, by all means use the <hr> tag.


If you just want a design line, you could use something like the css class

.hline-bottom {
    padding-bottom: 10px;
    border-bottom: 2px solid #000; /* whichever color you prefer */
}

and use it like

<div class="block_1 hline-bottom">Cheese</div>