What is a line break?
In HTML, a line break is used to start a new line within the text and maintain a space between two HTML elements. Line break is essential for formatting the contents of webpages as it increases clarity and readability of the webpage content.
To create a line break, you can use either <br> or <br/> HTML tag.
Example of Using Line Break
In the following example, we have a paragraph (<p>) element containing text - 'There will be a break from here.<br/> The line after the break.'. But a line break has been inserted using the <br/> HTML tag before 'The line after the break'. As a result of using <br/> HTML tag, 'The line after the break' will be displayed at a new line. Let's have a closer look at the following example:
Example
Output of the above example
There will be a break from here.
The line after the break
Example of Using Line Break Between Two HTML Elements
In the following example, we have two paragraph (<p>) elements containing text - 'There will be a break from here. The line after the break.' and 'The above gap is due to the use of break. <br> or <br/> tag is used to create a line break.' But a line break has been inserted using the <br/> bwtween two paragraph elements. As a result of using <br/> HTML tag, there will be a space between two HTML elements. Let's have a closer look at the following example:
Example
Output of the above example
There will be a break from here. The line after the break.
The above space is created due to the use of break tag. <br/> tag is used to create a line break.