开发者

Any difference in xhtml between <img .... /> and <img ...></img> at all?

same as title, I'm pretty sure it has no difference, but just to be on the safe side with standard compl开发者_开发技巧iance.


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.


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.


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.


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

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


Both methods are xhtml w3C compliant


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜