Do you know what Br tag HTML is used for? Well, if you ever want to put a single line break between a paragraph or a line, then we use br tags in HTML.
These HTML tags help to add a single line break in our essays, poems, or other documentaries. Are you too confused about the uses of these Br tags in HTML? In this blog, we are going to clear your confusion around the <br> tags and highlight all the use cases of this HTML tag.
Br Tag HTML
The <br> tag in HTML plays an important role in forming well structured and readable content for your webpage or blogs. Simply, <br> tags are used as a “line breaker.” Web browsers do not recognise line breaks or new paragraphs automatically and must be explicitly declared in the HTML document.
You can insert a single line break in your text wherever you might need it. In HTML documents, <br> tags are used in place of the ‘Enter’ or ‘Return’ button.
Br Tag HTML Key Takeaways
- <br> tags in html are used to add a single line break.
- It can be used with event attributes as well as global attributes.
- HTML br tag is self closing. You do not need to use a closing tag for <br> as it is an empty element.
Uses of Br tag HTML
The <br> tags are a self closing element used to insert a single line breaker. It does not add any space between the elements, it just changes the line.
Line Breaks in paragraphs
In web development, we use <br> tags to create line breaks within a paragraph.
<p>This is the first line. <br>This is the second line. </p> |
Address Formatting
The Br tag html is used to display addresses in a formatted manner where each part is arranged in a separate manner.
<address>
123 Example Street<br> Cityville, CA 12345<br> USA </address> |
Form Layouts
When we are creating form elements for our web page, we use <br> tags to separate input fields or labels.
Name: <input type=”text”><br>
Email: <input type=”email”> |
Syntax
<br> |
Attributes
Attribute Value | Description |
|
It is used to indicate from where the line break starts. |
Examples of HTML Br Tag
Let us understand the implementation of <br> tags in html with the help of an example given below.
<!DOCTYPE html>
<html lang=”en”> <head> <meta charset=”UTF-8″ /> <meta name=”viewport” content=”width=device-width, initial-scale=1.0″ /> <link rel=”stylesheet” href=”style.css” /> </head> <body> <h2>Event Day!</h2> <p> Hello Folks! hope you are having a great day.</p><br> <p> Thankyou! for being here today.</p> <script src=”script.js”></script> </body> </html> |
Supported Browsers for Br tag HTML
Nowadays, all major browsers support <br> tags in their web browsers. However, the supported list of web browsers are mentioned below.
Common Confusions with the uses of <br> tags in HTML?
The <br> tags in HTML are a line breaker element used to give a separate line where it is being used. It is unlike a space bar, people often use the <br> tags for creating a spacing between the paragraphs or blocks of text. However, it is an inappropriate practice and must be avoided.
Some developers also heavily rely on the usage of <br> tags in HTML. However, one can use CSS for layout, margins, and padding for a structured layout. Overuse of <br> tags might make the code less readable and harder to maintain.
Many of us are confused about whether to use a closing tag with <br> or not. Well, br tags in html are self closing elements that contain nothing, basically an empty container that declares where the line break starts. In HTML5 you can just write <br> tags and be done. However, in XHTML open tags are also closed using a closing tag.
<!– HTML5: →
This is the first line.<br>This is the second line. <!– XHTML: → This is the first line.<br />This is the second line. |
Some of us also take <br> as a tag which might create a horizontal spacing between a block of letters or paragraphs. However, <br> tags only create vertical single line breaks.
Learn Full Stack Development with PW Skills
Excited about web development? Enrol in our Full Stack Development Course and master tools and frameworks to begin your career as a backend or front end developer.
This 6 month program is completely packed to help master web development fundamentals, tools, and concepts suitable for beginners as well as a working professionals. Participate in real-time projects with experienced mentors from the industry. Build your job portfolio and prepare for thousands of interview opportunities coming your way only at pwskills.com
Recommended Course
- Generative AI Course
- Python DSA Course
- Devops Course
- UI UX Course
- Digital Marketing Course
- Product Management Course
Br tag html FAQs
Q1. What is the br tag in html?
Ans: Br tag html is used as a line breaker within a paragraph or block of line. It is basically used to change the line using br> syntax.
Q2. Is the tag self closing?
Ans: Yes, the br tag html is self closing and does not require a closing /br> tag. It is an empty container and hence does not require closing tags.
Q3. Does br tag provide horizontal spacing?
Ans: No, br> tag in html only provides vertical spacing by breaking the line where it is declared.
Q4. Should I use br/> or br?
Ans: You can use
tags. However, you might use br /> or br /> tags as well.