没有href和没有名称的锚标签是否有效? [英] Is it valid HTML to have an anchor tag without href and without name?

查看:137
本文介绍了没有href和没有名称的锚标签是否有效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有效的HTML有没有href和没有名字的锚标签?在我们的应用程序中,我们有一些删除链接被禁用(因此没有 href 属性),但仍显示给用户。






我代表 Joshua Muheim ,这是在相关问题的评论中提出的。这与原来的问题非常相似,但不同的是,我觉得将它作为一个单独的问题打开是值得的。 div>

是的,它是有效的, HTML规范说


如果 a 元素没有 href 属性,那么元素表示一个占位符,表示一个链接可能被放置的位置,如果它是相关的,则只包含元素的内容。



Is it valid HTML to have an anchor tag without href and without name? In our app we have some delete links which are disabled (hence no href attribute), but still shown to the user.


I am posting this question on behalf of Joshua Muheim which was asked in the comments of a related question. It is very similar to the original question, but different enough that I felt it was worthwhile to open it as a separate question.

解决方案

Yes it's valid, the HTML spec says:

If the a element has no href attribute, then the element represents a placeholder for where a link might otherwise have been placed, if it had been relevant, consisting of just the element's contents.

这篇关于没有href和没有名称的锚标签是否有效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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