Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it still necessary to put a space before closing an empty element in XHTML?

W3C recommends putting a space before the closing tag in XHTML, because this would give a better backwards compability with some browsers, e.g. write <br /> instead of <br/>. But are there still browsers out there, that would not tolerate that you omitted the space? (W3C do not mention which browsers cause problems.)

I know it doesn't make much of a diffence. I just prefer the shorter version. So unless there is a good reason I will now start coding my XHTML without spaces before closing empty tags.

like image 485
Jan Aagaard Avatar asked Nov 20 '08 14:11

Jan Aagaard


2 Answers

It's for Netscape 4.

I still include it out of habit, and my templating library will put them in for me anyway, but it's questionable whether it's really that important today.

like image 149
bobince Avatar answered Oct 24 '22 21:10

bobince


I would say no... It was to support Netscape 4, as bobince said, and I believe the number of such browsers being really in use is very near zero, fortunately!
Unlike what Vincent said, I don't think IE4 has such issue. And I believe we can class IE3/4/5/5.5 as dead anyway (at least gone of Web statistics), and waiting impatiently to do the same for IE6 too! :-D

Silly thing, this has influenced so many people that sometime I see x="foo" /> even pure XML files!

like image 37
PhiLho Avatar answered Oct 24 '22 22:10

PhiLho