xhtml self-closing anchor element allowed?

2019-04-11 02:55发布

If I make an anchor element and don't want text within it, because I'm gonna to css-i-fy it with a nice image and a hover-effect... I wonder if it is legal to write <a id="hoverimage" href="google.com" /> validome.org & validator.w3.org say YES ?

BTW: anyone knows an equivalent to alt element for this case?

标签: html css xhtml
1条回答
我欲成王,谁敢阻挡
2楼-- · 2019-04-11 03:47

It is valid in XHTML. It is not HTML-Compatible so likely to break in a document served as text/html. Having a link with no content is bad practise (background images are not content (which is why there is no equivalent to the alt attribute)).

查看更多
登录 后发表回答