Difference between <br> and <br />

it sounds silly,
whats the difference between <br> and <br />

The first is used in HTML, the second is used in XHTML. They are not compatible (you must use the first in HTML only, and the second in XHTML only).

For a more technical answer, XHTML requires all elements [edit: without closing tags] to be “self-closed” (it’s in the rules). Adding a space and a forward slash before the end of the tag “self-closes” the element, in this case <br> becomes <br /> which is technically the same as <br></br>

(Although, to be really REALLY technical, the space is not even required, it just helps make the tag easier to read by us mere puny humans with our flawed primate vision.)

AutisticCuckoo has a great thread [URL=http://www.sitepoint.com/forums/showthread.php?t=393445]found here, worth reading on top of what Dan has already covered. :slight_smile:

Additionally, Post #12 and below has some interesting info related to self-closing tags and xhtml/xml… might be worth a glance. :slight_smile:

thanx guys

No problem. I forgot to mention that the self-closing “rule” in XHTML only applies to elements that do not have corresponding closing tags. (like IMG, BR, META and so on)

I’ve edited my post to reflect that. Sorry if I confused you.

Also, IE 6 does not support XHTML just to let you know. I would imagine IE 7 does but who knows with Microsoft’s Internet Browsers these days…

IE 7 doesn’t support true XHTML either. You have to “fake it” by sending it as text/html instead.

Unbeliebable. Completly unbeliebable

From what I’ve heard, IE 8 won’t support it either.

However, Microsoft has said they’re doing it this way because they want to fix the problems in IE first before tackling true XHTML and XML support, and when they do tackle it, they want to get it right the first time.

I’m supposing they really mean “their way” rather than the “right way” of course ;).

Which will really disappoint our grand children once it’s released.

Lol mPeror, they will be very disapointed.

Shouldn’t they spend a bit more time on IE7 then fixing the bugs in it, rather than just spreading out all the different bug fixes over all the different versions.

I’ve just come out of hybernation from html in 1998. So what’s the difference for a web page? Both seem to work okay. Wouldn’t it be up to the browser to be compatible and translate what <br> or <br /> means?

Have you read this thread?