Discussion in 'Programming & Webmastering' started by rakkhi, Jan 24, 2011.
Can any one tell me what is the difference between <br> and <br /> tag.
The first is a tag from HTML, the second is from XHTML (the shorttag version of "<br></br>")
Read up here: http://www.w3schools.com/XHTML/xhtml_html.asp
Also is is very important to set your document's DOCTYPE to the language you're using, HTML is not the same as XHTML, HTML3 not the same as HTML4, "HTML 4.01 Transitonal" not the same as "HTML 4.01 Strict" and so on! Otherwise you'll get "guesswork" from the browser! This is very important!
More here: http://www.w3schools.com/tags/tag_doctype.asp
Use this validator to see if you made errors in your page (browsers should actually reject these with a "syntax error"): http://validator.w3.org/
<br> is HTML 4.01 is Loose and Transitional compliant.
<br /> is HTML 4.01 Loose, Transitional, and Strict compliant.
The reason for the ending slash is because in XML, all tags must be closed. <br> is considered an opening tag and so is <img>. <br /> and <img /> tells parsers there is no ending tag. An XML interpreter would see <br> and look for a </br> which doesn't exist in the markup.
<br /> is considered "proper."
Separate names with a comma.