HTML br (line break) element creates a line break or carriage-return in text within an HTML document. It is useful for writing a poem or an address, where the division of lines is significant.
HTML br element is an inline element.
<br> tag inserts a single line break. The text after the
<br> begins again at the start of the next line of the text block.
HTML br element requires start tag only. The
<br> element is classified as a “void element” as it has no content.
HTML br element can reside within inline as well as block level elements.
<br> tag is an empty tag which means that it has no end tag.
If you place the <br> tag in the HTML code, then it works the same as pressing the enter key in a word processor.
HTML <br> Tag Example
<!DOCTYPE html> <html lang="en"> <head> <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>HTML <br> Tag Example</title> </head> <body> <h1>A Poem</h1> <p>Be not afraid of greatness.<br> Some are born great,<br> some achieve greatness,<br> and others have greatness thrust upon them.</p> <p><em>-William Shakespeare</em></p> </body> </html>
What is the correct way of using <br>, <br/>, or <br /> in HTML?
You can use HTML br tag three ways: <br> or <br/> or <br />. It is recommended to use closed br tag <br/> because it is supported in HTML and XHTML both.
In XHTML, the valid way is to use <br/> or <br></br> as mentioned in the XHTML guidelines.
As per w3 guidelines, a space should be included before the trailing / and > of empty elements, for example, <br />.
In HTML, use <br> tag.