**Learn How to Insert a Horizontal Line in HTML**
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:
```
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:
Size and Color
You can use the size and color attributes to change the line's thickness and color respectively. Here's an example:
```
The output will be a thick blue line. You can adjust the values to suit your needs.
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:
Center Align
To center the line, use align="center":
```
Right Align
To right align the line, use align="right":
```
Understanding how to align your horizontal lines allows you to create more visually appealing webpages.
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:
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.
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!