views:

75

answers:

6

same as title, I'm pretty sure it has no difference, but just to be on the safe side with standard compliance.

+5  A: 

If your document is served as XHTML (application/xhtml+xml), then there is no difference. If it's served as HTML (text/html), only the first form is going to be parsed "correctly" by an HTML parser.

See this post for a related question.

Chris Jester-Young
sorry, I missed that one. thanks for showing it to me.
sombe
Although its not "parsed correctly" ... the closing tags for HTML are optional while The self closing tag is ignored. still valid HTML, just not W3C compliant these days.
Reed Debaets
A: 

No difference. Self closing tags are just the short way of getting the same job done.

just like c++ is that same as c+=1 and c=c+1 ... just cuts down on typing.

Reed Debaets
A: 

No there is no difference for any XML element in any XML document.

<img .../> is just a shortcut for <img...></img>

Brian R. Bondy
A: 

Both methods are xhtml w3C compliant

Ruth
A: 

<img /> is the recommended way: http://www.freewebmasterhelp.com/tutorials/xhtml/2

Gerrie Schenck
A: 

This is not just a theoretical different in what is parsed "correctly". There's actually a practical difference.

When served as text/html to browsers other than IE, the "/" in the first case and </img> in the second case will be ignored, and the DOM created in both cases will be the same.

In IE however, in the second case the </img> is not ignored and results in an additional element in the DOM called "/IMG". It's possible for this to effect the workings of scripts that might be on the page.

Alohci