The HTML <br> tag inserts a single line break. A <br> tag is an empty tag which means that it has no end tag like other HTML tags(<p> tag, <div> tag, etc).
HTML <br> Tag :-
- It inserts a single line break .
- It is an empty tag without any end tag.
Here are few question on br tag can confused you in interview.
Which one use in HTML5: Is it <br>, <br/>, or <br />?
Answers: Simply <br>
tag is sufficient to break a line in HTML.
See below example:
<!DOCTYPE html>
<html>
<body>
<p>Text for break <br>HTML Horizontal line</p>
</body>
</html>
Output:
Read more: HTML Line Break br tag complete tutorial
Which is correct, </br> or <br/>?
Answers: Using <br> is just the correct and best way, no need for the forward slash. <br/>
<br />
<!DOCTYPE html>
<html>
<body>
<p>Text for break <br/>HTML Horizontal line</p>
<p>Text for break </br>HTML Horizontal line</p>
</body>
</html>
What is the difference between <br> and <br/> tag in HTML? Which one should we use?
Answers: The main difference between <br> and <br\> are :
HTML (up to HTML 4): use <br>
HTML 5: <br>
is preferred, but <br/>
and <br />
is also acceptable.
XHTML: <br />
is preferred. Can also use <br/>
or <br></br>.
<br /> is backwards-compatible with XHTML and well-formed HTML (ie: XHTML) is often easier to validate for errors and debug.
Do comment if you have any doubt and suggestion on this tutorial.