Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the main difference of <br> and <br />

Tags:

html

What is the main difference between <br> and <br /> in html markup? Can someone explain the main difference of the two because it's confusing to me. Thanks in advance for all of your comments. :)

like image 305
ggtaetiseo Avatar asked Feb 14 '15 05:02

ggtaetiseo


People also ask

Is BR the same as br />?

If you are outputting HTML on a regular website you can use <br> or <br/> , both are valid anytime you are serving HTML5 as text/html. If you are serving HTML5 as XHTML (i.e. content type application/xhtml+xml, with an XML declaration) then you must use a self closing tag like so: <br/> .

What does br /> mean?

<br>: The Line Break element. The <br> HTML element produces a line break in text (carriage-return).

What is the difference between BR tag?

< P > tag is used in front of the each paragraph on the webpage whereas </P > tag at the end of each paragraph on the webpage. (b) < BR > : The < BR > tag stands for Break and is used to instruct the web browser to break the text the text and go to a new line. this helps to control where the text breaks.

Is there a difference BR?

Both br and br/ produces the same result i.e line break. But br/ is preferred because it can be used with strict rules as well(like while writing XHTML document) and the latter looks cleaner and readable.


1 Answers

In practice, </br> does not exist. Just <br> or <br />.

However, the difference is the position, and is universal for all XML tags. <TAG_NAME> indicates the beginning of a tag, and </TAG_NAME> indicates the end of a tag. When a tag is used with nothing between it, then a self-closing, or null tag can be used, which combines the beginning and end. It looks like <TAG_NAME />.

In XML, any tag can be self closing, however, with HTML, only tags which are defined as such should be used that way. So you should never do <div />, instead you should use <div></div>, even if it's empty. Some self closing tags in HTML are, as already noted, <br />, also things like <param />, <input /> and <track />. You can view the full list here.

So, basically, elements in the link above are allowed to be self closing. They often have attributes to indicate their data, but no additional elements are allowed inside of them. Other elements, which can have additional elements inside of them require both <TAG> and </TAG> to be complete.

Note that under less strict rules, in HTML, self closing tags do not require the ending slash, so <br> is equivalent to <br />. However, the latter form is preferred, and much cleaner looking. Also, any tags that aren't self closing, that aren't closed property (i.e. has a </TAG>) will cause you a nightmare because elements will have a parent who should be a sibling.

Hope that helps.

like image 62
David Avatar answered Oct 03 '22 15:10

David