br, hr Tags
The br
tag creates a line break on a web page, while the hr
tag draws a horizontal line.
1. <br>
Tag
-
The
<br>
tag stands for "Break" and is used to insert a line break in a web page. For example, when entering text like poetry where each verse starts on a new line, you can use<br>
. -
Using the
<br>
tag in text editing is similar to pressing the 'Enter' key.
Example of Using the <br>
Tag
Example of the br Tag
<p>First line<br />Second line</p>
Notes
The <br>
tag is empty, meaning it does not have a closing tag. Simply insert <br>
or <br/>
wherever you want to add a line break in the document.
The tags <br>
and <br/>
are functionally the same, but HTML5 recommends using <br>
.
2. <hr>
Tag
- The
<hr>
tag stands for "Horizontal Rule" and is used to create a horizontal line on a web page. It is commonly used to visually separate content sections.
Example
Example of the hr Tag
<p>Paragraph 1</p>
<hr />
<p>Paragraph 2</p>
Notes
Like the <br>
tag, the <hr>
tag is also self-closing and does not require a closing tag. The appearance of the line (thickness, color, etc.) can be customized using CSS.
Want to learn more?
Join CodeFriends Plus membership or enroll in a course to start your journey.