<br> vs <br /> what is the difference, and which is better?

froggyboy604

Seasoned Veteran
Joined
Oct 22, 2007
Messages
3,165
Reaction score
1
FP$
5,109
I see some websites use <br> and other websites use <br />. Which one is better for creating a line break?
 
Re: <br> vs <br /> what is the difference, and which is bett

They are the same.
 
Re: <br> vs <br /> what is the difference, and which is bett

No they are different. <br /> is xHTML and supported by more browsers. <br> is standard HTML.
 
Re: <br> vs <br /> what is the difference, and which is bett

Thanks death180 for the explanation. I think I use <br /> from now on.
 
Re: <br> vs <br /> what is the difference, and which is bett

Although both are correctly understood by all the most recent (by recent I mean, 2008 and later) browsers (including the horrible IE), <br /> is a better coding practice, and is a more recent approach because it is XHTML.

XHTML is the same as HTML, but XHTML is considered as the evolution of HTML, thus is better (in my opinion) to use XHTML. XHTML is based on the XML markup and that's why even single tags like <br /> and <img source="..." /> need to have the closing slash (/) in the end preceded by a space ( ).

HTML5 (in development) is considered by some as the successor of XHTML
Read more about this on the usual site...
http://wikipedia.org/wiki/XHTML

PS: if you really want to know my own opinion, nowadays browsers understand basically all the types of HTML, from HTML1 to HTML5 including XHTML, and they even parse correctly mixtures of these standards, and I don't really follow a standard. Let's say my HTML is something between HTML4.1 and XHTML. 😀
 
Re: <br> vs <br /> what is the difference, and which is bett

If you want to be W3C valid though you would want to stay consistent and correct.
 
Re: <br> vs <br /> what is the difference, and which is bett

Yeah, you should do the same with <input> tags and <hr> (horizontal rule) tags.
 
Re: <br> vs <br /> what is the difference, and which is bett

death180 said:
If you want to be W3C valid though you would want to stay consistent and correct.
I'm aware of that. As I use PHP and CSS mostly now, it's easy to stay within the rules, as on most complex PHP scripts, on some files there is almost no HTML (and styles are defined though CSS).
 
Re: <br> vs <br /> what is the difference, and which is bett

<br/> is better, Because this support more browser.
 
Re: <br> vs <br /> what is the difference, and which is bett

I always used <br /> when coding.
 
Re: <br> vs <br /> what is the difference, and which is bett

Ofcourse it is best from other.
 
Re: <br> vs <br /> what is the difference, and which is bett

gbl08ma said:
Although both are correctly understood by all the most recent (by recent I mean, 2008 and later) browsers (including the horrible IE), <br /> is a better coding practice, and is a more recent approach because it is XHTML.

XHTML is the same as HTML, but XHTML is considered as the evolution of HTML, thus is better (in my opinion) to use XHTML. XHTML is based on the XML markup and that's why even single tags like <br /> and <img source="..." /> need to have the closing slash (/) in the end preceded by a space ( ).

HTML5 (in development) is considered by some as the successor of XHTML
Read more about this on the usual site...
http://wikipedia.org/wiki/XHTML

PS: if you really want to know my own opinion, nowadays browsers understand basically all the types of HTML, from HTML1 to HTML5 including XHTML, and they even parse correctly mixtures of these standards, and I don't really follow a standard. Let's say my HTML is something between HTML4.1 and XHTML. 😀
XHTML is an XML based language, you forgot that.
 
Re: <br> vs <br /> what is the difference, and which is bett

<br /> is what I've always used.
 
Re: <br> vs <br /> what is the difference, and which is bett

But if you validate it with the W3 validation, you need the DTD to be xhtml and not html or it will say thats an error.
 
Re: <br> vs <br /> what is the difference, and which is bett

I just found this out the other day when I was following some tutorials 😛
 
Re: <br> vs <br /> what is the difference, and which is bett

I was wondering the same thing. Going to start using <br /> from now on.
 
Back
Top Bottom