1. Home
  2. Knowledge Base
  3. code
  4. html
  5. Create a horizontal line (dividing line) with HTML
  1. Home
  2. Knowledge Base
  3. WordPress
  4. Create a horizontal line (dividing line) with HTML

Create a horizontal line (dividing line) with HTML

To visually separate two sections from each other, a dividing line, for example, could be a good idea. That’s why you can find out here how you can easily create a horizontal line with HTML.

How to make a horizontal line in HTML

For the separator line, you only need the following HTML element in HTML: <hr>
The “hr” stands for “horizontal ruler”. The <hr> can basically be installed anywhere in the <body> and does not require a closing element.

Example:

This is a text above the dividing line


The text below

<p>Dies ist ein Text oberhalb der Trennlinie</p>
<hr>
<p>Der Text unterhalb</p>

Change the appearance of the horizontal line

Of course, the appearance of the HTML horizontal line can be changed using CSS. As with any other HTML element, we use the style attribute to define the CSS code.

The HTML attributes size, color, width, align and noshade should no longer be used because they are obsolete and are no longer supported in HTML5. Instead, the appearance should be defined using CSS.

Change color

The color of the line can be changed with the CSS instruction border-color

Example 1:


<hr style="border-color: green;">

Example 2:


<hr style="border-color: #ff0000;">

Change height

The height of the line can be changed with the CSS instruction border-width

Example 1:


<hr style="border-width: 5px;">

Example 2:


<hr style="border-width: 20px;">

Change width

The width of the line can be changed with the CSS instruction width.

Example 1:


<hr style="width: 50px;">

Example 2:


<hr style="border-width: 80%;">

Dieser Beitrag ist auch verfügbar auf: Deutsch (German)

Was this article helpful?

Related Articles

Submit a Comment

Your email address will not be published. Required fields are marked *

Skip to content