The <hr> Element in HTML

The <hr> element is used to insert a horizontal line on a webpage. It represents a thematic break — for example, when you want to separate sections of content or signal a shift in topic.

Think of <hr> as a visual divider that helps make your page easier to read and navigate. It’s useful between paragraphs, sections, or headings when you want to clearly separate ideas. The <hr> tag is self-closing, which means it does not need a closing tag.

hr element - Educodes

Understaning the layout of the <hr> Element

Start tagElement contentEnd tag
<hr>nonenone

Note: Some HTML elements have no content (like the <hr> element). These elements are called empty elements. Empty elements do not have an end tag!

📘 Example Code

Below is an HTML example showing a title, a paragraph, and a horizontal line:

💡 This is what the code looks like inside an editor

<!DOCTYPE html> <html> <head> <title>Horizontal Line Example</title> </head> <body> <h1>My Travel Blog</h1> <p>Welcome to my travel stories and tips.</p> <hr> <p>Here you will find guides, photos, and travel recommendations.</p> </body> </html>

🖥️ What This Will Look Like in a Browser

✅ Example output you would see on a webpage:

Welcome to my travel stories and tips.


Here you will find guides, photos, and travel recommendations.

🧪 Time to Practise!

Now it’s your turn to create your own line divider using the <hr> tag.

Try this example first:

<p>Traveling makes life exciting!</p>
<hr>
<p>Let's explore the world together.</p>

What To Do

✅ Type the code above in the editor below
✅ Click Test Code to see the result
✅ Try changing the sentences to your own text
✅ Experiment by placing <hr> between different paragraphs or sections

Tip 💡

Use <hr> when you want to visually separate content and make your page look clean and professional.
It helps guide the reader and makes your webpage easier to follow — just don’t overuse it!
Keep practising and you’ll continue building strong HTML formatting skills! 🚀

HTML Editor

Live Preview

👉 Continue to the next lesson and learn how the <strong> tag makes important text stand out.

Educodes Logo

© Copyright 2024. | Educodes