HTML - <br> Tag



In HTML, a paragraph usually begins on a new line, but what if you want content within a paragraph to begin on a new line. In that scenario’s we are going to use the HTML line break.

A line break in a text can be made using the HTML <br> tag. When the division of a line is required, it is used. Being an empty tag, it is not dependent on an end tag. The <br> tag behaves just like pressing the enter key in a word workstation, when it is used in the HTML code.

Syntax

Following is the syntax of the <br> tag −

<p> …content <br> …content <br> …content </p>

Example

In the following example, let's see the usage of the <br> element in the HTML documents as follows −

<!DOCTYPE html>
<html>
<body>
   <p align="center">Geckos are a group of usually small, usually nocturnal lizards. <br> They are found on every continent except Antarctica. </p>
</body>
</html>

On running the above code, you can see that the <br> begins again at the start of the next line of the text block.

Example

Let's look at the another scenario, where we are going to use the <br> tag to print the address in the new line.

<!DOCTYPE html>
<html>
<body>
   <p>Mozilla <br /> 331 E. Evelyn Avenue <br /> Mountain View, CA <br /> 94041 <br /> USA <br />
   </p>
</body>
</html>

On running the above code, the output window will pop up, displaying the address that begins on a new line where the <br>tag is used.

Example

Considering the following example, where we are going to use the<br> tag to display each input field in the new line.

<!DOCTYPE html>
<html>
<body>
   <form>
      <input type="text" placeholder="Enter your name" />
      <br>
      <input type="phone" placeholder="Enter your phone" />
      <br>
      <input type="email" placeholder="Enter your email" />
   </form>
</body>
</html>

When we run the above code, it will generate an output consisting of the three input fields separated by the <br> tag to make each input field start on a new line.

html_tags_reference.htm
Advertisements