What's the diff between html code <br> and <br /> ?

Savarak

Platinum Member
Oct 27, 2001
2,718
1
81
apparently none, although I believe <br> is a true valid form, and <br /> must be a typo
 

neit

Senior member
Dec 6, 2001
353
0
0
I think it has something to do with xml. I was looking a few months ago and XHTML has to conform to XML standards, part of which is that everything needs a closing tag. since a break doesn't have a closing tag, its included by having the space-slash in the tag itself.

w3schools.com should be able to verify/clarify this.
 

igowerf

Diamond Member
Jun 27, 2000
7,697
1
76
Shahbazq has it right. In the XHTML standard, all tags have to be closed, including the ones that are just a single tag like br or img.
 

Zugzwang152

Lifer
Oct 30, 2001
12,134
1
0
Originally posted by: igowerf
Shahbazq has it right. In the XHTML standard, all tags have to be closed, including the ones that are just a single tag like br or img.

this is the correct answer. <br> is HTML, <br /> is XHTML. browsers interpret tham as the same thing.
 

Savarak

Platinum Member
Oct 27, 2001
2,718
1
81
his question was about html not xhtml, but i learned something today ;) cool.
 

CycloWizard

Lifer
Sep 10, 2001
12,348
1
81
New protocols (xml) require every tag to be closed. <br> is really only an opening tag. Any tag <x> can be opened and closed in one go as <x /> if you don't want to enclose any content within the tag. In short, <br /> is the correct way to insert a line break. <br> theoretically won't work after backwards compatibility is removed, though it doesn't look like that will ever really happen, so it probably doesn't matter.
 

Drakkon

Diamond Member
Aug 14, 2001
8,401
1
0
Originally posted by: notfred
you can use <br></br> if you want.
yeah but do that and some stupid browsers out there give u two line breaks instead of one ;)
 

torpid

Lifer
Sep 14, 2003
11,631
11
76
Also, it's important to have the space there for browser compatibility. Browsers that don't support <br/> will just ignore the / if it's not adjacent to the main tag.
 

homercles337

Diamond Member
Dec 29, 2004
6,340
3
71
Originally posted by: shahbazq
I think it has something to do with xml. I was looking a few months ago and XHTML has to conform to XML standards, part of which is that everything needs a closing tag. since a break doesn't have a closing tag, its included by having the space-slash in the tag itself.

w3schools.com should be able to verify/clarify this.


That be it...
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Just cause no one's mentioned it yet: closing every tag has been in the latest html standard for 5 or 6 years now (yes xhtml is html). I don't know why anyone would start using the old version.

Oh, and lol @ jediknight :)
 

Czar

Lifer
Oct 9, 1999
28,510
0
0
use <br />

it is the new standard
its only a matter of time when <br> stops working (could take a looong time though)
and I see no reason not to :p
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
<br> won't stop working (or at least it shouldn't) as long as you have the proper doctype at the top of your page.
 

igowerf

Diamond Member
Jun 27, 2000
7,697
1
76
Originally posted by: Czar
use <br />

it is the new standard
its only a matter of time when <br> stops working (could take a looong time though)
and I see no reason not to :p

I think <br /> is only for XHTML though. You shouldn't use it if your DOCTYPE is for HTML. It'll still work though.
 

Czar

Lifer
Oct 9, 1999
28,510
0
0
Originally posted by: igowerf
Originally posted by: Czar
use <br />

it is the new standard
its only a matter of time when <br> stops working (could take a looong time though)
and I see no reason not to :p

I think <br /> is only for XHTML though. You shouldn't use it if your DOCTYPE is for HTML. It'll still work though.

true, but xhtml is the new standard
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
Originally posted by: Czar
Originally posted by: igowerf
Originally posted by: Czar
use <br />

it is the new standard
its only a matter of time when <br> stops working (could take a looong time though)
and I see no reason not to :p

I think <br /> is only for XHTML though. You shouldn't use it if your DOCTYPE is for HTML. It'll still work though.

true, but xhtml is the new standard

Newness isn't a virtue in and of itself.

http://www.hixie.ch/advocacy/xhtml

In the end, the rabid self-righteous standards-obsessed web movement is mostly a waste of energy. Yes, it is good to write sensible html; yes, CSS is handy; yes, tables can be a nightmare -- but in the end, what does it really matter? The only people that really care are other web nerds who are just as rabid, just for the sake of being rabid. Your site will work just fine in HTML 4 or (god forbid) non-100%-valid HTML.

By the time <br> stops working (hah), we will probably have much bigger problems to worry about. No one controls the web and browser makers are not going to cause millions of sites to display incorrectly just for the hell of it.

</rant> :p

edit: haha, this guy is great:
My third reason to refuse the validation circus is the most personal and least technical one. It's an emotional matter. My rationality has taken a holiday.

To me, the standards and (especially) the way we should implement them have taken on the insufferable air of a dogmatic, uncreative religion that only exists to enforce its arbitrary rules about what to do and how to think, ministered by a self-proclaimed caste of bigot priests.

I feel like starting a movement or something.