HTML HTML Tutorial HTML Forms HTML Graphics HTML Media HTML APIs HTML Tags



HTML Tag: hr

The HTML tag hr stands for horizontal rule. It is a self-closing tag that creates a horizontal line or rule on a web page. The hr tag is used to visually separate content on a web page, such as sections or paragraphs. It is a simple and effective way to improve the readability and organization of a web page.

The hr tag has been a part of HTML since the beginning and is supported by all modern web browsers. It is a very basic and easy-to-use tag that can be used by anyone, regardless of their level of expertise in web development.

Code Examples

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

Example 1: Basic Usage

The most basic usage of the hr tag is to create a horizontal line:

<hr>

This will create a horizontal line that spans the width of the container it is in:


Example 2: Styling the Line

The hr tag can be styled using CSS to change its appearance. Here is an example:

<hr style="color: red; border-style: dotted;">

This will create a red dotted line:


Example 3: Using Attributes

The hr tag also supports several attributes that can be used to further customize its appearance. Here are some examples:

<hr size="10" color="blue" align="center">

This will create a blue line that is 10 pixels thick and centered:


<hr noshade>

This will create a line without a shadow:


Conclusion

The hr tag is a simple and effective way to visually separate content on a web page. It is easy to use and can be customized using CSS and attributes. By using the hr tag, web developers can improve the readability and organization of their web pages.

References

Activity