Can a span be nested in a link in HTML5?
I've often placed <span>
elements inside if a <a>
element in XHTML transitional.
I'm writing against HTML5 right now and Visual studio 2010 tells me that it's illegal in HTML5.
Is this c开发者_高级运维orrect? If so, what would be the best way to style a portion of the text inside of a link an alternate color?
According to the W3C Validator, this is valid HTML5:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<a><span>text</span></a>
</body>
</html>
So: yes, that's valid in HTML5.
What would be the best way to style a portion of the text inside of a link an alternate color?
Use CSS! If your markup looks something like this:
<a><span>Normal text,</span> <span class="abby-normal">different text</span></a>
Then your CSS might look something like this:
a > span.abby-normal {
color: #F00;
}
Now, if Blücher
was a valid color...
精彩评论