- Home
- /
- Tutorials
- /
- HTML Tutorial
- /
- HTML <hr> Tag
HTML Tags
HTML <hr> Tag
The hr tag draws a horizontal line, but its real meaning is "change of topic": a scene change in a story, or a shift to a new subject. Use it where you would leave a gap in a printed text.
<hr> is a void element: no closing tag, nothing inside it. Write it on its own line between two paragraphs or sections.
Syntax
html
<hr>There are no special attributes. Old attributes like size, width, color and noshade are obsolete; use CSS instead.
Example
html
<!DOCTYPE html>
<html>
<head>
<title>HR Tag Example</title>
<style>
.styled-hr {
border: 0;
height: 4px;
background: linear-gradient(to right, #29AB87, #2ecc71);
border-radius: 2px;
}
</style>
</head>
<body>
<h1>Horizontal Rule Example</h1>
<p>This is the first section of text.</p>
<!-- Horizontal line separating sections -->
<hr class="styled-hr" title="Section Break">
<p>This is the second section of text after the horizontal rule.</p>
</body>
</html>A green gradient line separates the two paragraphs. The CSS sets border: 0 first, which removes the browser's default grey line, and then draws a new one with a height and background.
Styling the line
A simple, subtle divider
css
hr {
border: 0;
border-top: 1px solid #e2e8f0;
margin: 2rem 0;
}The default <hr> is drawn with borders, so changing only color or background often seems to do nothing. Remove the border first, then style it the way you want.
Browser Support
Chrome | Edge | Firefox | Safari | Opera | IE9+ |
|---|---|---|---|---|---|
| Yes | Yes | Yes | Yes | Yes | Yes |
Good to know
HTML <hr> Tag exercises
Mark a change of topic
Write two paragraphs, The day ended. and Next morning it rained. Between them mark a change of topic.
Result
