We use the <br>
element in HTML to create a line break in the text. It helps restructure the text by moving the proceeding text to the next line.
The <br>
tag is different from most other tags because it is an empty tag, which means it does not need an end tag. It supports general
This tag does not need to be styled with CSS, as it only creates a line break in a block of text. It has no visual attributes or dimensions which would require styling.
However, the spacing allowed by the <br>
tag can be adjusted with the margin
property.
Using the <br>
tag to create new paragraphs is not good practice. Screen readers cannot announce the content contained between <br>
elements as it is an empty tag. As such, it does not enclose a piece of text. This can cause confusion for those using a screen reader to read.
Instead, we should use the <p>
tag for paragraphs.
The following example shows how we can use the <br>
tag in HTML:
<!DOCTYPE html><html lang="en"><head> <!--- meta-data about the webpage ---><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title> "br Element Code Example</title></head><body><p> <!--- new paragraph --->Hello! <br> I hope this helped. <!--- moves the text after "Hello" to a new line ---></p></body></html>
Free Resources