It's not a lot more than curiosity,
which is the difference between <br> and <br /> ?
I see both of them widely used and abused, are they completely interchangeable ?
It's not a lot more than curiosity,
which is the difference between <br> and <br /> ?
I see both of them widely used and abused, are they completely interchangeable ?
Short version: the two notations are about different serializations, not different rendering. As and pointed out, the slash-style is the XML/XHTML-friendly form. In practice, when a page is parsed as HTML (most sites using the HTML5 doctype), browsers accept either form. If a page is actually served as XML (true XHTML), empty elements must follow XML well-formedness and use the self-closing form.
How to tell which applies to your page:
<!DOCTYPE html> means the document will be parsed with HTML rules. If the server sends the document with the MIME type application/xhtml+xml, it is parsed as XML and you must use XML syntax. A quick check:
curl -I https://example.com/page | grep -i content-type A few practical notes and troubleshooting tips:
For authoritative details about how browsers treat empty/void elements and how HTML vs XML parsing differ, see MDN’s notes on the line-break element and the HTML spec’s section on void elements: MDN — Line break element and WHATWG HTML — Void elements.
Jump to Post— essential 84This
<br>tag is best used in HTML format using( .html extension ) and this<br />tag goes with XHTML (or .xhtml saved document ).
Jump to Post— pspwxp fan 1It's not a lot more than curiosity,
which is the difference between <br> and <br /> ?I see both of them widely used and abused, are they completely interchangeable ?
<br/> is used in XHTML which is a much stricter form of html :) .
Jump to Post— essential 84
<br/> <!-- or --> <br />it doesn't matter as long as you are using it with the correct doctype.
This <br> tag is best used in HTML format using( .html extension ) and this <br /> tag goes with XHTML (or .xhtml saved document ).
It's not a lot more than curiosity,
which is the difference between <br> and <br /> ?I see both of them widely used and abused, are they completely interchangeable ?
<br/> is used in XHTML which is a much stricter form of html :) .
So in any case there are no cons using <br/> instead of <br> even in "simple" HTML ?
<br/> is the same withot space btw 'r' and '/' ?
<br/> <!-- or --> <br /> it doesn't matter as long as you are using it with the correct doctype.
<br/> <!-- or --> <br />it doesn't matter as long as you are using it with the correct doctype.
I don't get it, can you please show me with an example the relation to the doctype?
The space is there in <br /> to make the self-closing tags compatible with IE 6 and earlier. IE renders it wrong without the space.
the main difference between <br > and <br /> is <br> is used html earlier versions and <br /> is used in the latest version like the below tags also
<img src="" > ------------- <img src="" />
<b> </b>---------------- <strong> </strong>
<i> -------------- <em> </em> Ok, so it's definitely better to use <br /> in any case from my pov...
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.