Table of contents
1.
Introduction 
2.
What is <br> Tag in HTML? 
3.
Syntax of HTML <br> Tag 
4.
Attributes of <br> Tag in HTML
5.
Example of HTML <br> tag?
5.1.
HTML Code
5.2.
HTML Code
5.3.
HTML Code
6.
Difference Between <br> and <br/> in HTML
7.
Supported Browsers
8.
Frequently Asked Questions 
8.1.
What is <br> tag in HTML?
8.2.
How to use <br> tag in HTML table?
9.
Conclusion 
Last Updated: Oct 7, 2024
Easy

HTML <br> tag

Author Gunjan Batra
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction 

HTML, the backbone of web development, provides a set of tags to structure and present content. In the world of line breaks, the <br> tag plays a crucial role. Short for "break," this tag is a simple yet powerful tool for controlling the flow of text and elements on a webpage. This blog explores the HTML <br> tag, unraveling its functionality, use cases, and the impact it has on the visual presentation of content. 

<br> tag in HTML

What is <br> Tag in HTML? 

<br> tag in HTML gives you a line break in the text. This is an empty tag, meaning it has no end tag. <br> tag is generally used in writing poems, addresses, or where it is required to add a break in the text. The tag can be used anywhere, i.e., clubbed with other tags. 

Syntax of HTML <br> Tag 

Although, <br> tag has no such specified syntax. It is used with its name enclosed in angular brackets. 

<br> 

Attributes of <br> Tag in HTML

The <br> tag in HTML is a void element, meaning it doesn't have a closing tag. It doesn't have specific attributes like many other tags. It's used to insert a line break in the document.

Example of HTML <br> tag?

  • HTML Code

HTML Code

<!DOCTYPE html>

<html lang="en">

<head>

 <meta charset="UTF-8" />

 <meta name="viewport" content="width=device-width, initial-scale=1.0" /> 

<title>Web Page</title>

</head

<body>

 <h1>

   Hello Ninjas!

 </h1>

 <p>

   Welcome to yet another interesting article. <br>In this blog, we will learn about br tag.

</body>

</html>

 

Output

Output

We can see in the above code that the sentence gets broken out after using the <br> tag. The tag itself has no such specified output. It only has a little purpose except to break the text. It is not compulsory to use <br> tag with other tags. The tag can be directly used in the body to separate text. 

Let’s see the below example for this:

  • HTML Code

HTML Code

<!DOCTYPE html>
<html lang="en">
<head>
<title>First Web Page</title>
</head>
<body>
Chrome<br>Internet Explorer <br> Microsoft Edge <br> Opera Mini <br> Brave <br>Safari
</body>
</html>

 

Output 

output

You can see in the above code that <br> tag is used in the body part of HTML. You can also add margins and text spacing using the <br> tag, but it is advisable to use something other than the <br> tag for this purpose. The CSS stylesheet has margins and various height properties for spacing and height of the text. 

 Let’s achieve the above output without using the <br> tag. 

  • HTML Code

HTML Code

<!DOCTYPE html>

<html lang="en">

<head>

   <title>First Web Page</title>

</head>

<body>

 <p>Chrome</p>

 <p>Internet Explorer </p>

 <p> Microsoft Edge </p>

 <p> Opera Mini </p>

 <p>Brave</p>

 <p> Safari</p>

</body>

</html>

 

Output

output

Difference Between <br> and <br/> in HTML

The primary difference between <br> and <br/> in HTML lies in their usage and syntax:

1. Syntax:

<br>: Traditional syntax for line breaks in HTML.
<br/>: Self-closing syntax, recommended in XHTML and HTML5 for consistency and compatibility. It's also accepted in HTML.

2. XHTML and HTML5:

<br>: Commonly used in HTML documents without closing tag.
<br/>: Preferred in XHTML and HTML5 for self-closing tags.

3. Compatibility: Both are generally supported across browsers, but <br/> is more consistent with XML rules. In HTML5, both <br> and <br/> are accepted, providing flexibility.

4. Common Usage:

<br>: Widely used in HTML for line breaks.
<br/>: More commonly used in contexts adhering to XHTML or HTML5 standards.
 

In practice, for HTML5, both forms are accepted, but for XHTML and consistency, <br/> is often recommended. For HTML, <br> is more commonly used due to its simplicity.

Supported Browsers

The <br> tag, which represents a line break in HTML, is universally supported across all major web browsers. This includes popular browsers such as:

  1. Google Chrome
  2. Mozilla Firefox
  3. Apple Safari
  4. Microsoft Edge
  5. Internet Explorer
     

The consistent support for the <br> tag ensures that line breaks are rendered consistently across different browsers and platforms, providing a standard way to control the layout and spacing of content within HTML documents.

Frequently Asked Questions 

What is <br> tag in HTML?

<br> tag gives you a single line break in the text. This tag is used in poems, addresses, or where there is a need to break the lines. 

How to use <br> tag in HTML table?

To add line breaks in an HTML table, use <br> within table cell content to move text or elements to a new line.

Conclusion 

In this blog, we thoroughly discussed <br> tag in HTML. We learned about its syntax, usage, and examples of using <br> tag, and we also discussed the reason for not using the <br> tag in HTML. 

To learn more about HTML, and its tags, please refer.

Also, check out some of the Guided Paths as well as some Contests, Test Series, and Interview Experiences curated by top Industry Experts.

Ha

Live masterclass