html - 具有没有 href 且没有名称的 anchor 标记是有效的 HTML 吗?

标签 html hyperlink html-validation

没有 href 和名称的 anchor 标记是否有效?在我们的应用程序中,我们有一些删除链接被禁用(因此没有 href 属性),但仍向用户显示。


我代表 Joshua Muheim 发布这个问题在 comments of a related question 中被问到.它与原始问题非常相似,但差异很大,我觉得值得将它作为一个单独的问题打开。

最佳答案

是的,它是有效的,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.

关于html - 具有没有 href 且没有名称的 anchor 标记是有效的 HTML 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16302694/

相关文章:

html - 只有链接框中的文本是可点击的

asp.net - 在指向 ASP.Net Web 应用程序的 Excel 超链接中使用查询字符串

html - 带有 <!DOCTYPE HTML> 的“charset=iso-8859-1”发出警告

javascript - 验证我用 document.write() 编写的 html 文档

javascript - 我想访问 javascript 函数内的输入字段,其 id 是使用 php 代码生成的

css - 为什么#wrapper 的背景颜色没有显示在左侧和内容列的后面?

javascript - iPhone 键盘在 contenteditable 上输入时会隐藏文本

html - CSS 中可见性和显示的优先顺序

JavaScript - 当我更改链接的 href 时未定义链接

html - HTML 错误算作 WCAG 错误吗?