8

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.

Jan Aagaard
  • 10,363
  • 7
  • 41
  • 73

4 Answers4

9

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.

bobince
  • 514,530
  • 102
  • 640
  • 820
  • 4
    Technically, this isn't correct. I just tested Netscape Navigator 4.08 and it handles this just fine. Netscape 3.0, however, does not. If you're going to care about either of those, though, you'll have rather a few more pressing problems to worry about. – mercator Jul 09 '09 at 22:31
1

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!

PhiLho
  • 39,674
  • 6
  • 93
  • 131
0

If there are still browsers that rely on the space use it.

The amount of bytes saved does not justify the possible problems.

Toon Krijthe
  • 51,960
  • 37
  • 141
  • 201
0

The point of backward compatibility is to still support the browsers that do NOT support the short notation. There's probably still a lot of those out there.

I guess your choice might depend on the target audience of the website (e.g. a tech site will have more visitors using a recent browser, as opposed to seniors.net, visited by people using Win 95 and IE 4).

Vincent Van Den Berghe
  • 5,325
  • 2
  • 30
  • 39