While building a website using HTML, you will definitely find a need to control how your content is displayed. One common task is adding line breaks, so that users can read the content easily. That’s where the <br> tag in HTML comes into play..
In this blog, we will help you understand everything about the <br> tag, from what it is and when to use it with real-life examples. Whether you’re a beginner in web development or just brushing up on your HTML basics, this blog will help you understand the <br> element in HTML.
Table of Contents:
What is HTML?
HTML stands for Hypertext Markup Language. It is defined as the markup Language used to structure content on the web. Every webpage you visit daily is built using HTML.
<br> Tag in HTML
The <br> tag in HTML stands for “Break”. It is used to add a line break in your content. In Simple words, when you want to move text to the next line without starting a new paragraph, then the <br> tag is used.
If you think of pressing Enter in the code, then it doesn’t work in the code. That’s why we use the <br> tag—to tell the browser explicitly to break the line.
Note:
- The <br> tag is self-closing, which means you don’t need a closing tag (</br>).
- It is used within other HTML tags like <p>, <div>, or <td>
Learn to Code Beautiful Websites
Join Today
Syntax
The Syntax of the <br> tag is very simple. It doesn’t need a closing tag because it’s an empty Tag(which doesn’t require a closing tag).
<br>
Attributes of <br> Tag
Attributes in HTML are defined as special words that are used to provide special properties to the HTML elements. As such <br> tag doesn’t have any of its own attributes, but it uses some global attributes (Attributes that can be applied to most of the tags).
Attributes |
Description |
id |
It is used to assign a unique identifier to the tag. |
class |
You can assign one or more class names for CSS. |
style |
It is used to add inline CSS styling. |
title |
It is used to add a tooltip on hover. |
Use Cases of <br> Tag
The <br> tag is best used when you need to break a line without starting a new paragraph. Here are some other important use cases:
Addresses usually have multiple lines, and using the <br> tag helps in formatting them neatly.
Example: Address Formatting
The <br> tag is commonly used when designing forms in HTML. It is used to separate labels and input fields on different lines.
Example: Simple Form
3. For Writing Poems, Quotes, or Song Lyrics
It is useful for adding content like poems or lyrics to the webpage.
Browser Compatibility
Since it is a basic part of HTML, you do not need to think much about its browser support. Here is the list of browsers that support the <br> tag widely:
- Google Chrome
- Mozilla Firefox
- Microsoft Edge
- Safari
- Opera
- Mobile Browsers (iOS/Android)
Best Practices for Using <br> Tag
Here are some of the best practices that you need to follow while using the <br> Tag in HTML:
- Use <br> only when you want to break a line without writing a new paragraph.
- The <br> tag is not for spacing or positioning elements on a page. Use other CSS properties like margin, padding, or grid for spacing and positioning of <br>.
- Multiple <br> tags in a row can make your code messy, and thus, programmers find it difficult to read the code.
- Instead of using <br> to separate blocks of content, use semantic tags like <section>, <header>, etc.
Get 100% Hike!
Master Most in Demand Skills Now!
Conclusion
The <br> tag in HTML is a small but important tag for beginners. It helps to improve the structure and the readability of content on a webpage. It stands for “break” and is used to insert a single line break within text, without starting a new paragraph. Unlike container tags like <div>, <p>, and <ul>, it doesn’t require any closing tag (</br>). This makes it easy to use, and in HTML5, simply writing <br> is perfectly valid. One of the amazing things about the <br> tag is its wide browser support. You will create professional websites by using the <br> tag.
HTML <br> Tag – FAQs
Q1. What are
and
tags in HTML?
The <br> tag is used to insert a line break and move the content to the next line.. The <hr> tag, on the other hand, stands for a horizontal rule. It is used for adding a horizontal line across the page.
Q2. What is the full form of
?
The full form of <br> is “break”, specifically referring to a line break in HTML.
Q3. Is
an empty tag?
Yes <hr> tag in HTML is the empty tag that means it doesn’t require any closing tag.
Q4. How to bold in HTML?
You can use <strong> or <b> tag, any one of them to make text bold.
Q5. What is a
tag?
The <li> tag stands for “list item” and is used inside ordered (<ol>) or unordered (<ul>) lists for defining the items in a list.