开发者

XHTML inline div inside anchor tag

I want to have an image roll-over link and use sprites. Is it ok to do put an inline div inside an anchor with no text?

<a href="l开发者_高级运维ink.html"><div style="display:inline;background:etc;"></div></a>


No, according to the W3C a div may not live inside an a element, unless you're declaring the doctype as HTML5*. Also, why would you use a div and make it display:inline if a span does the same and is standards-compliant at the same time?

 * http://davidwalsh.name/html5-elements-links


No, block level elements aren't allowed inside inline level elements, and will cause undefined behaviour. Use a span instead.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜