how to add a horizontal line in html

**Learn How to Insert a Horizontal Line in HTML**

By Rachel King
AD

Horizontal lines in HTML are often used to separate content, add visual breaks, or highlight important sections. They can greatly enhance the readability of your webpages. So, how do you add a horizontal line in HTML?

It's actually quite simple. You can use the <hr> element to create a horizontal rule. Here's an example:

Basic Horizontal Line

The most basic usage of the <hr> tag is to create a line across the page. Here's how you do it:

AD
How to Add a Horizontal Line to a Chart in Google Sheets
How to Add a Horizontal Line to a Chart in Google Sheets
How to Draw Horizontal Line & Vertical Line in Website by HTML & CSS(Simple & Easy)
How to Draw Horizontal Line & Vertical Line in Website by HTML & CSS(Simple & Easy)
Draw the Line: How to Use the @ Symbol to Insert a Horizontal Line in Google Docs - Teacher Tech with Alice Keeler
Draw the Line: How to Use the @ Symbol to Insert a Horizontal Line in Google Docs - Teacher Tech with Alice Keeler
```html
```

The output will be a horizontal line that stretches across the page. You can adjust the line's appearance using CSS if desired.

Customizing the Line

While the basic <hr> tag creates a simple line, you can also customize its appearance. Let's explore some attributes to achieve this:

HTML Line Breaks Explained: <br> Tag for Beginners | Part 1
HTML Line Breaks Explained: <br> Tag for Beginners | Part 1
✨ The <hr> Tag – Horizontal Rule
✨ The <hr> Tag – Horizontal Rule
a notepad with sticky notes on it next to some pens and pencils,
a notepad with sticky notes on it next to some pens and pencils,

Size and Color

You can use the size and color attributes to change the line's thickness and color respectively. Here's an example:

```html
```

The output will be a thick blue line. You can adjust the values to suit your needs.

AD

Aligning the Horizontal Line

By default, the <hr> tag creates a line that's left-aligned. But what if you want to align it differently? You can use the align attribute:

HTML Horizontal Line – HR Tag Example
HTML Horizontal Line – HR Tag Example
a computer screen with the text smart pc care by yoi
a computer screen with the text smart pc care by yoi
How to Insert a Line in Word (4 Creative Ways) | Royalwise
How to Insert a Line in Word (4 Creative Ways) | Royalwise
HTML Header Navigation Bar Hover using CSS
HTML Header Navigation Bar Hover using CSS
How to Style Horizontal Rule HTML (hr tag) on WordPress
How to Style Horizontal Rule HTML (hr tag) on WordPress
How to give title to work in HTML
How to give title to work in HTML

Center Align

To center the line, use align="center":

```html
```

Right Align

To right align the line, use align="right":

AD
```html
```

Understanding how to align your horizontal lines allows you to create more visually appealing webpages.

a computer screen with some type of text on it
a computer screen with some type of text on it
How to Add a Horizontal Line Separator in WordPress (5 Ways)
How to Add a Horizontal Line Separator in WordPress (5 Ways)
the css border radius is shown in black and white, with text below it
the css border radius is shown in black and white, with text below it

Using Horizontal Lines with CSS

While the <hr> tag gives you basic control over your horizontal lines, CSS allows for more advanced styling. Here's how you could create a line using pure CSS:

```html
```

This will create a 3-pixel black horizontal line that stretches across the div. You can adjust the line's style using the CSS properties you prefer.

AD

Responsive Design

When designing for responsive layouts, it's important to ensure your horizontal lines adjust well to different screen sizes. This can be achieved with a combination of HTML and CSS.

In conclusion, adding a horizontal line in HTML is straightforward. Whether you're creating a basic line, aligning it, or styling it with CSS, these techniques can help you create more engaging and readable webpages. Happy coding!

AD