xhtml自封闭锚元素< a />允许? [英] xhtml self-closing anchor element <a /> allowed?

查看:125
本文介绍了xhtml自封闭锚元素< a />允许?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我做一个锚点元素,不想要的文字,因为我要css-i-fy它有一个漂亮的图像和悬停效果...
我想知道如果它是合法的写< a id =hoverimagehref =google.com/>
validome.org& validator.w3.org说

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:对于这种情况,任何人都知道等价于alt元素?

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

推荐答案

这是在XHTML a>。它是不与HTML兼容,因此可能会在作为文本/ HTML的文档中断开。拥有一个没有内容的链接是不好的做法(背景图片不是内​​容(这就是为什么没有等同于alt属性))。

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)).

这篇关于xhtml自封闭锚元素&lt; a /&gt;允许?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆