What's the difference between these two tags?? "<br> and <br />

Recommended Answers

<br> is an empty tag, it must close on open tag. In XHTML <br> tag must close in open tag, <br />

Jump to Post

html is fairly flexible in its structure, incomplete code is accepted by the parser
the xhtml specification is much more strict
in xhtml all tags must close
eg <a></a>
singleton tags such as <img><br> must self close as <img /> <br />

Jump to Post

"does that change anything"
validation errors in xhtml code, and
some browsers may fail to display the tag/page (depending on the number of code errors)

xhtml has strict structure rules
must use self closed tags, period

stuff we use a lotthese standard test beds may assist you

Jump to Post

All 12 Replies

<br> is an empty tag, it must close on open tag. In XHTML <br> tag must close in open tag, <br />

html is fairly flexible in its structure, incomplete code is accepted by the parser
the xhtml specification is much more strict
in xhtml all tags must close
eg <a></a>
singleton tags such as <img><br> must self close as <img /> <br />

This means that it doesn't close an opened tag at all.. It closes itself by adding the slash to the end of it (with a space before).

Thank you but what if I used the <br> instead of <br />??
does that change any thing like the layout for instance??
thanx

we must practise to do it in correct format. Better you use <br /> <img />. Though it will not change layout, if you do not add space and slash.

"does that change anything"
validation errors in xhtml code, and
some browsers may fail to display the tag/page (depending on the number of code errors)

xhtml has strict structure rules
must use self closed tags, period

stuff we use a lotthese standard test beds may assist you

http://analyze.websiteoptimization.com/authenticate.php?url=http://www.yoursite.com&/ Speed tweaks

http://validator.w3.org/check?uri=http%3A%2F%2Fwww.yoursite.com&charset=%28detect+automatically%29&doctype=Inline&group=0 html check

http://jigsaw.w3.org/css-validator/validator?uri=http%3A%2F%2Fwww.yoursite.com&profile=css21&usermedium=all&warning=1&lang=en CSS2 check http://jigsaw.w3.org/css-validator/validator?uri=http%3A%2F%2Fwww.yoursite.com&profile=css3&usermedium=all&warning=1&lang=en CSS3 check

http://demo.opera-mini.net/demo.html?www.yoursite.com handheld

http://www.browsershots.org other browsers
many problems (if present) will show
serious code errors in the w3c validator sites will produce blankscreens in browsershots

Valid code does not ensure the site will work ...
Invalid code ensures the site will not work ...
.. in all browser OS combinations

not all layouts work in handheld devices
strictly code based,

commented: Thank you for wasting your time to help me. +2

Thanks a lot..

we must practise to do it in correct format. Better you use <br /> <img />. Though it will not change layout, if you do not add space and slash.

This is incorrect. XHTML is NOT HTML. If it was, then XHTML would be called HTML5. If your page is not parsing XML data then the XHTML doctype should not be used. <br> is valid HTML, <br /> is valid XHTML, while <br> and <br /> are valid HTML5.

Regards
Arkinder

commented: Impolite way of correcting other people -1
commented: Doesn't sound impolite to me. +15
commented: Arkinder is apparently trying to help not more!! +3
commented: Arkinder is trying to help, there is nothing impolite about this post +10

Since when is stating facts impolite? Would smiley faces and rainbow stickers make my posts better? It's never my intention to come across as rude or impolite (with the exception of that one time with almostbob ^_^). I simply make my points and leave. Text is very open to interpretation, and it's really out of my control if someone takes what I said the wrong way.

Regards
Arkinder

Since when is stating facts impolite? Would smiley faces and rainbow stickers make my posts better? It's never my intention to come across as rude or impolite (with the exception of that one time with almostbob ^_^). I simply make my points and leave. Text is very open to interpretation, and it's really out of my control if someone takes what I said the wrong way.

Regards
Arkinder

Thanks, sometimes everyone needs a hit in the head, even me

Thanks, sometimes everyone needs a hit in the head, even me

No problem. ^_^ The same definitely goes for me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.