- HTML Tutorial
- HTML - Home
- HTML - History and Evolution
- HTML - Overview
- HTML - Editors
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Headings
- HTML - Paragraphs
- HTML - Quotations
- HTML - Comments
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Style Sheet
- HTML - CSS Classes
- HTML - CSS IDs
- HTML - Images
- HTML - Image Map
- HTML Tables
- HTML - Tables
- HTML - Headers & Caption
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Iframes
- HTML - Blocks
- HTML Backgrounds
- HTML - Backgrounds
- HTML Colors
- HTML - Colors
- HTML - RGB
- HTML - HEX
- HTML - HSL
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Code Builder
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
HTML - <hr> Tag
The HTML <hr> element represents a thematic break between paragraph-level elements: for example, a change of scene in a story or a shift of topic within a section. Or it is displayed as a horizontal rule that is used to separate content (or define a change) in an HTML page.
The <hr> element takes an attribute color that is used for coloring the horizontal line. And this tag supports both global attributes and event attributes in HTML.
Syntax
Following is the syntax of <hr> tag −
<!Doctype html> <html> <body> <p> …content </p> <hr> </body> </html>
Example
Let's consider the following example, where we are creating an HTML document that shows the behavior of the <hr> tag.
<!DOCTYPE html> <html> <body> <p> This is the first paragraph of text. This is the first paragraph of text. This is the first paragraph of text. This is the first paragraph of text. </p> <hr /> <p> This is the second paragraph of text. This is the second paragraph of text. This is the second paragraph of text. This is the second paragraph of text. </p> </body> </html>
When we run the above code, it will generate an output consisting of the text displayed on the webpage along with a horizontal line between them.
Example
In the following example, we are creating an HTML document and modifying the <hr> tag using the CSS properties as follows −
<!DOCTYPE html> <html> <head> <style> hr { border: none; border-top: 3px double #333; color: #333; overflow: visible; text-align: center; height: 5px; } hr:after { background: #fff; content: '§'; padding: 0 4px; position: relative; top: -13px; } </style> </head> <body> <h2>TutorialsPoint</h2> <hr> <p>§1: The first rule of Fight Club is: You do not talk about Fight Club. </p> <hr> <p>§2: The second rule of Fight Club is: Always bring cupcakes. </p> </body> </html>
On running the above code, the output window will pop up displaying the text along with a CSS applied hr tag on the webpage.
Example
Considering the following example, we are creating an HTML document and using the <hr> tag and its attributes that are not supported in HTML5, as follows:
<!DOCTYPE html> <html> <body> <h2>TutorialsPoint</h2> <hr align="left"> <p>The first rule of Fight Club is: You do not talk about Fight Club. </p> <hr align="noshade"> <p>The second rule of Fight Club is: Always bring cupcakes. </p> <hr size="10"> <p>This is paragraph! </p> <hr width="100"> <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. </p> </body> </html>
When we run the above code, it will generate an output consisting of the text and shows how <hr> tag works in HTML4.