HTML Code for Hr

Introduction to HTML <hr> Tag

The <hr> tag in HTML is used to create a thematic break or horizontal rule. It is a self-closing tag, which means it does not require a closing tag. The <hr> tag is commonly used to separate sections of a document.

Attributes of <hr> Tag

The <hr> tag does not have any required attributes. However, it supports the following optional attributes: 1. 'noshade': This attribute is no longer supported in HTML5 and its presence has no effect. 2. 'size': It specifies the height of the rule. The default value is browser-specific. 3. 'width': It sets the width of the rule. By default, it spans the entire width of the containing element.

Styling <hr> Tag with CSS

The <hr> tag can be styled using CSS to change its color, thickness, width, alignment, and more. CSS properties like 'border', 'border-color', 'height', 'margin', and 'width' can be used to style the <hr> tag.

Best Practices for Using <hr> Tag

1. Use <hr> tag sparingly and thoughtfully to improve readability and structure of the document. 2. It is recommended to style the <hr> tag using an external CSS stylesheet to maintain consistency across the website. 3. When using <hr> tag, consider its impact on the overall design and user experience.

Example Code


Go from files to website in seconds.

Start a free trial for 7 days — no credit card required

Get Started for Free