我经常放置 <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/