HTML Basic
HTML Reference
- HTML Tags
- <!--...-->
- <!DOCTYPE>
- <a>
- <abbr>
- <address>
- <area>
- <article>
- <aside>
- <audio>
- <b>
- <base>
- <bdi>
- <bdo>
- <blockquote>
- <body>
- <br>
- <button>
- <canvas>
- <caption>
- <cite>
- <code>
- <col>
- <colgroup>
- <data>
- <datalist>
- <dd>
- <del>
- <details>
- <dfn>
- <dialog>
- <div>
- <dl>
- <dt>
- <em>
- <embed>
- <fieldset>
- <figcaption>
- <figure>
- <footer>
- <form>
- <h1> to <h6>
- <head>
- <header>
- <hgroup>
- <hr>
- <html>
- <i>
- <iframe>
- <img>
- <input>
- <ins>
- <kbd>
- <label>
- <legend>
- <li>
- <link>
- <main>
- <map>
- <mark>
- <menu>
- <meta>
- <meter>
- <nav>
- <noscript>
- <object>
- <ol>
- <optgroup>
- <option>
- <output>
- <p>
- <param>
- <picture>
- <pre>
- <progress>
- <q>
- <rp>
- <rt>
- <ruby>
- <s>
- <samp>
- <script>
- <search>
- <section>
- <select>
- <small>
- <source>
- <span>
- <strong>
- <style>
- <sub>
- <summary>
- <sup>
- <svg>
- <table>
- <tbody>
- <td>
- <template>
- <textarea>
- <tfoot>
- <th>
- <thead>
- <time>
- <title>
- <tr>
- <track>
- <u>
- <ul>
- <var>
- <video>
- <wbr>
- HTML Deprecated Tags
- HTML Events
- HTML Global Attributes
- HTML Status Code
- HTML Language Code
- HTML Country Code
- HTML Charset
- MIME Types
HTML hr Tag
Photo Credit to CodeToFun
🙋 Introduction
The <hr>
tag in HTML is a simple yet powerful element used to create a horizontal rule, often referred to as a line or divider.
In this guide, we will delve into the various aspects of the <hr>
tag and how to leverage it effectively in your web development projects.
🤔 What is <hr> Tag?
The <hr>
tag is a self-closing tag that produces a horizontal line, typically used to separate content or sections within a webpage. It is a handy tool for visually dividing and organizing different parts of your content.
💡 Syntax
Implementing the <hr>
tag is straightforward, as it doesn't require a closing tag. Simply insert it within your HTML code where you want the horizontal line to appear.
<hr>
🧰 Attributes
While the <hr>
tag itself doesn't have many attributes, you can use the style attribute to customize the appearance of the horizontal rule. For example:
<hr style="color: #333; background-color: #333; height: 2px;">
📚 Common Use Cases
Section Separation:
One common use of the
<hr>
tag is to visually separate different sections of a webpage, providing a clear distinction between content.section-separation.htmlCopied<div> <h2>Section 1</h2> <p>Content for section 1...</p> <hr> </div> <div> <h2>Section 2</h2> <p>Content for section 2...</p> <hr> </div>
Thematic Break:
Use the
<hr>
tag as a thematic break to indicate a shift in topics or themes within your content.thematic-break.htmlCopied<p>Introduction to a topic...</p> <hr> <p>Exploring the main points...</p>
🖥️ Browser Support
Understanding the compatibility of the <hr>
tag across different browsers is essential for delivering a consistent user experience. Here's an overview of its support:
- Google Chrome: Fully supported.
- Mozilla Firefox: Fully supported.
- Microsoft Edge: Fully supported.
- Safari: Fully supported.
- Opera: Fully supported.
- Internet Explorer: Fully supported.
🏆 Best Practices
- Customize the
<hr>
tag using the style attribute to match your website's design. - Combine with CSS to add additional styling or effects.
- Ensure proper spacing before and after the
<hr>
tag for optimal visual presentation.
🎉 Conclusion
The <hr>
tag is a valuable tool for web developers looking to add structure and clarity to their content. By strategically placing horizontal rules, you can enhance the visual appeal and navigation of your webpages.
👨💻 Join our Community:
Author
For over eight years, I worked as a full-stack web developer. Now, I have chosen my profession as a full-time blogger at codetofun.com.
Buy me a coffee to make codetofun.com free for everyone.
Buy me a Coffee
If you have any doubts regarding this article (HTML hr Tag), please comment here. I will help you immediately.