The HTML ho­ri­zont­al line is a line that divides content on a website into two sections. The cor­res­pond­ing HTML <hr> tag does not require a closing element.

What is an HTML ho­ri­zont­al line?

An HTML ho­ri­zont­al line is used to draw a visible and con­tinu­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­ab­il­ity of a web page. <hr> is not only a visual dividing line, but also has semantic sig­ni­fic­ance because the element indicates that there is a change of topic or a thematic break.

The HTML tag can the­or­et­ic­ally be used anywhere within the body element and does not require a closing tag. The ab­bre­vi­ation ‘hr’ stands for ‘ho­ri­zont­al ruler’. HTML <hr> supports all HTML at­trib­utes and is supported by all common browsers.

Web hosting
The hosting your website deserves at an un­beat­able price
  • Loading 3x faster for happier customers
  • Rock-solid 99.99% uptime and advanced pro­tec­tion
  • Only at IONOS: up to 500 GB included

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

You don’t need any at­trib­utes or para­met­ers to implement the ho­ri­zont­al 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 ho­ri­zont­al line. The cor­res­pond­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 ho­ri­zont­al line visually separates the text passage from the quote.

How to customise ho­ri­zont­al lines in HTML

Before HTML5 was in­tro­duced, the at­trib­utes align, color, noshade, size and width were used to customise ho­ri­zont­al lines in HTML. Since, however, they are no longer supported, you can use the CSS attribute style to make changes to ho­ri­zont­al 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 colour of a ho­ri­zont­al 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 ho­ri­zont­al 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 ho­ri­zont­al 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
Register your domain name
Launch your business on the right domain
  • Free WordPress with .co.uk
  • Free website pro­tec­tion with one Wildcard SSL
  • Free Domain Connect for easy DNS setup
Go to Main Menu