HTML hr Tag: create separators and dividers on your webpage

HTML <hr> Tag - Definition, Usage, Syntax, Attributes, Best Practices, and Examples

HTML hr Tag

{tocify} $title={Table of Contents}

Definition

The HTML <hr> tag is a self-closing tag that stands for “horizontal rule”. It's a visual element to create a horizontal line or divider on a web page. 

The <hr> tag is often used to separate web page sections, such as different paragraphs, images, or other content.

Usage:

The <hr> tag creates a horizontal rule, or line, on a web page. It can be used to visually separate content, create a divider between page sections, or emphasize a break in the content.

Syntax:

The <hr> tag is a self-closing tag, which means it does not require a closing tag. 

Here's the syntax for the <hr> tag:

<hr>{codeBox}

Attributes:

The <hr> tag has several attributes that can be used to customize its appearance and behavior:

  • align: This attribute specifies the horizontal alignment of the <hr> tag. It can be set to "left", "center", "right", or "justify".

  • color: This attribute specifies the color of the <hr> tag. It can be set to any valid color value, such as a color name, RGB value, or hexadecimal value.

  • size: This attribute specifies the height of the <hr> tag. It can be set to a numerical value, such as "1" or "2", or to a relative value, such as "1em" or "1%".

  • width: This attribute specifies the width of the <hr> tag. It can be set to a numerical value, such as "100" or "200", or to a relative value, such as "50%" or "80%".

HTML <hr> Tag: Examples

Here are some examples of how the <hr> tag can be used:

<p>This is the first paragraph of text.</p>
<hr>
<p>This is the second paragraph of text.</p>
<hr color="red" size="2">
<p>This is the third paragraph of text.</p>
<hr width="50%">
<p>This is the fourth paragraph of text.</p>
<hr align="center">
<p>This is the fifth paragraph of text.</p>{codeBox}

In this example, the <hr> tag is used to create a horizontal rule between each paragraph of text. 

The first <hr> tag uses the default style, while the second <hr> tag is colored red and has a height of 2 pixels. 

The third <hr> tag is set to 50% width, while the fourth <hr> tag is centered. The final <hr> tag uses the default style again.

Best Practices:

Here are some best practices to keep in mind when using the <hr> tag:

  • Use the <hr> tag sparingly. Too many horizontal rules on a page can make it look cluttered and difficult to read.

  • Use the align, color, size, and width attributes sparingly as well. It's best to keep the appearance of the <hr> tag simple and consistent across your site.

  • Use CSS to style the <hr> tag, rather than relying on the default browser styles. This will give you more control over the appearance of the tag and ensure that it looks consistent across different browsers.

Calculation:

The HTML <hr> tag is a useful and simple tool for creating horizontal lines or dividers on a web page. 

It's commonly used to separate different sections of content or to emphasize breaks in the content. 

When using the <hr> tag, it's important to keep in mind some best practices, such as using it sparingly and using CSS to style it, in order to ensure a consistent and professional appearance. 

With these tips in mind, you can effectively use the <hr> tag to enhance the design and readability of your web pages.

Conclusion:

Friends, according to my expertise, I have written complete information to help you with “HTML <hr> Tag” If this post is favourable for you or not, please tell me by commenting.

If you liked this post, do not forget to share it with your friends so they can get information about it.

You can ask us through comments if you still have questions or doubts, I will answer all your questions, and you can contact us for more information.

Please tell us through the comment section if you think we miss anything.

To be published, comments must be reviewed by the administrator.*

Previous Post Next Post