html - span 可以嵌套在 HTML5 的链接中吗?

标签 html

我经常放置 <span> if a <a> 中的元素XHTML 过渡元素。

我现在正在写反对 HTML5 的文章,Visual Studio 2010 告诉我它在 HTML5 中是非法的。

这是正确的吗?如果是这样,将链接内的部分文本设置为替代颜色的最佳方式是什么?

最佳答案

根据W3C Validator ,这是有效的 HTML5:

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<a><span>text</span></a>
</body>
</html>

所以:,这在 HTML5 中是有效的。

What would be the best way to style a portion of the text inside of a link an alternate color?

使用 CSS!如果您的标记看起来像这样:

<a><span>Normal text,</span> <span class="abby-normal">different text</span></a>

那么你的 CSS 可能看起来像这样:

a > span.abby-normal {
    color: #F00;
}

现在,如果 Blücher 是一种有效的颜色...

关于html - span 可以嵌套在 HTML5 的链接中吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5439145/

相关文章:

html - CSS 目标 Internet Explorer 和屏幕宽度

html - 垂直对齐容器中的文本

javascript - 开关没有保持关闭状态,我必须单击按钮才能关闭开关

javascript - $this->input->post() 在 codeigniter 中总是空的

php - 使用 CSS 定位 PHP 代码

javascript - 如何检索 HTML 变量的第一个 div

html - 与 Flexbox 相同的宽度

javascript - HTML5 Canvas : How to border a fillRect?

javascript - 动态地在 Canvas 元素上绘图

html - 带有固定标题和可滚动正文的表格内的工具提示