HTML <br> Tag
HTML <br>
tag is a powerful tool for controlling the layout of your text. Unlike word processors, web browsers don’t automatically recognize new lines or paragraph formatting. This is where the <br>
tag comes into play.
The <br>
tag is a self-closing element, meaning it doesn’t require a closing tag. It’s commonly used in addresses, poetry, or any situation where a line break is needed for better readability.
Note: The <br>
tag also supports the Global Attributes and Event Attributes in HTML.
Syntax:
<br>
Attributes:
Attribute Value | Description |
---|---|
clear | It indicates where to begin the next line after the break. |
Examples of HTML br Tag
1. Using br Tag to Line Break the Content:
Example 1: In this example, we use <br> tag in p tag to line break the content.
<!DOCTYPE html>
<html lang="en">
<head>
<title>HTML5 br Tag</title>
</head>
<body>
<h2>w3wiki</h2>
<!--br tag is used in below paragraph-->
<p>Hi Beginner!
<br>Welcome to w3wiki
</p>
</body>
</html>
Output:
HTML br tag
Let us consider an example. Type the following HTML code does not use the <br> tag in notepad, save the document as an HTML file, and open it in a browser. You will notice that the text shows line breaks at four instances, the browser displays the entire text as a single paragraph.
2. Using br Tag to Add Line Break:
Example 2: This example explains the use of the <br> tag to add the line-break.
<!DOCTYPE html>
<html>
<body>
<h1>w3wiki</h1>
<h2>br Tag</h2>
<!-- br tag -->
<p>
w3wiki:<br>
Computer science portal
</p>
</body>
</html>
Output:
HTML br tag
Supported Browsers:
- Google Chrome 1
- Edge 12
- Firefox 1
- Opera 15
- Safari 4
Contact Us