Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML formatting conventions: Why leave a space before />?

I’ve seen it in several places and e.g. the Eclipse XML auto-formatting does it, too: Put a space before the closing /> of an empty element.

Having

<element attribute="value"/>

would be re-formatted as

<element attribute="value" />

Why would you do that? From the XML point of view it’s equivalent. Is it a convention? Is it for readability?

like image 420
hfs Avatar asked Nov 21 '12 15:11

hfs


1 Answers

It is likely done to be safe with XHTML XML, which requires the space in some early XHTML browsers.

Better answer: Space Before Closing Slash?

like image 97
Mark A. Fitzgerald Avatar answered Sep 20 '22 13:09

Mark A. Fitzgerald