The HTML hor­i­zon­tal line is a line that divides content on a website into two sections. The cor­re­spond­ing HTML <hr> tag does not require a closing element.

What is an HTML hor­i­zon­tal line?

An HTML hor­i­zon­tal line is used to draw a visible and con­tin­u­ous dividing line between two para­graphs or other mean­ing­ful sections in an HTML document. It is defined with the HTML <hr> tag and is used to improve the structure and read­abil­i­ty of a web page. <hr> is not only a visual dividing line, but also has semantic sig­nif­i­cance because the element indicates that there is a change of topic or a thematic break.

The HTML tag can the­o­ret­i­cal­ly be used anywhere within the body element and does not require a closing tag. The ab­bre­vi­a­tion “hr” stands for “hor­i­zon­tal ruler”. HTML <hr> supports all HTML at­trib­ut­es and is supported by all common browsers.

Web Hosting
Hosting that scales with your ambitions
  • Stay online with 99.99% uptime and robust security
  • Add per­for­mance with a click as traffic grows
  • Includes free domain, SSL, email, and 24/7 support

What is the syntax of HTML <hr> and how is it used?

You don’t need any at­trib­ut­es or pa­ra­me­ters to implement the hor­i­zon­tal line element in HTML, making the syntax for HTML <hr> simple:

<hr>
html

We’ll il­lus­trate how this element works with a simple example. Below, we’re going to take a paragraph (<p>) and a quoted text (<blockquote>) and separate them in our HTML document using a hor­i­zon­tal line. The cor­re­spond­ing code looks like this:

<!DOCTYPE html>
<html>
<body>
<h1>HTML horizontal line</h1>
<p>HTML is the standard markup language used to create documents for display on the web. It outlines the structure of a web page and enables the definition of text, images, links and various other elements.</p>
<hr>
<blockquote>“HTML is easy to learn and provides a solid foundation for creating websites.”</blockquote>
</body>
</html>
html
Image: Example of an HTML horizontal line
The hor­i­zon­tal line visually separates the text passage from the quote.

How to customize hor­i­zon­tal lines in HTML

Before HTML5 was in­tro­duced, the at­trib­ut­es align, color, noshade, size and width were used to customize hor­i­zon­tal lines in HTML. Since, however, they are no longer supported, you can use the CSS attribute style to make changes to hor­i­zon­tal lines in HTML.

Use this code instead of align:

<!DOCTYPE html>
<html>
<body>
<h1>HTML horizontal line</h1>
<p>HTML is the standard markup language for documents that are to be displayed on the web. It describes the structure of a website and makes it possible to define text, images, links and other elements.</p>
<hr style="width:50%;text-align:left;margin-left:0">
<blockquote>“HTML is easy to learn and provides a solid foundation for creating websites.”</blockquote>
</body>
</html>
html

You can change the color of a hor­i­zon­tal HTML line with the color property:

<!DOCTYPE html>
<html>
<body>
<h1>HTML horizontal line</h1>
<p>HTML is the standard markup language for documents that are to be displayed on the web. It describes the structure of a website and makes it possible to define text, images, links and other elements.</p>
<hr style="color:yellow;background-color:gray">
<blockquote>“HTML is easy to learn and provides a solid foundation for creating websites.”</blockquote>
</body>
</html>
html

Instead of noshade, use the following code to include a hor­i­zon­tal line without a shadow:

<!DOCTYPE html>
<html>
<body>
<p>A normal horizontal line:</p>
<hr>
<p>With CSS:</p>
<hr style="height:2px;border-width:0;color:gray;background-color:gray">
</body>
</html>
html

You can change the height with height:

<!DOCTYPE html>
<html>
<body>
<p>A normal horizontal line:</p>
<hr>
<p>A horizontal line with a height of 50 pixels:</p>
<hr style="height:50px">
</body>
</html>
html

You can set the width of an HTML hor­i­zon­tal line with the width parameter:

<!DOCTYPE html>
<html>
<body>
<p>A normal horizontal line:</p>
<hr>
<p>A horizontal line with a width of 30 percent:</p>
<hr style="width:30%">
</body>
</html>
html
Domain Name Reg­is­tra­tion
Build your brand on a great domain
  • Free Wildcard SSL for safer data transfers 
  • Free private reg­is­tra­tion for more privacy
  • Free Domain Connect for easy DNS setup
Go to Main Menu