br, hr Tags
The <br>
tag creates a line break
in a web page, while the <hr>
tag creates a horizontal line
.
1. <br>
Tag
The <br>
tag stands for "Break" and it is used to insert a line break in a web page.
It functions like pressing the 'Enter' key while editing text.
For example, when inputting text such as poetry, where each line should start on a new line, you use <br>
.
Example Usage of br Tag
<p>First Line<br />Second Line</p>
Important Points
The <br>
tag does not require a closing tag. Simply insert <br>
or <br/>
at the point where you want to add a line break.
While both <br>
and <br/>
are valid, it is recommended to use <br>
in HTML5.
2. <hr>
Tag
The <hr>
tag stands for "Horizontal Rule" and it is used to insert a horizontal line in a web page.
It is commonly used to visually separate sections or content that changes within a document.
Example
<p>Paragraph 1</p>
<hr />
<p>Paragraph 2</p>
Important Points
Just like the <br>
tag, the <hr>
tag does not require a closing tag, and you can style the line's thickness or color using CSS.
Want to learn more?
Join CodeFriends Plus membership or enroll in a course to start your journey.