下面的代码是从 ASP:Menu 中的 StaticItemTemplate 生成的。
代码和链接随心所欲,但验证失败。
输出代码如下
<li>
<a class="level1 StaticMenuItemStyle" href="/Services.aspx">
<div class="StaticMenuItemStyle"
onmouseover="style.backgroundColor='#0088CB';style.color=white;"
onmouseout="style.backgroundColor='';"
style="color:Color [Blue];width:180px;">
<a href="/Services.aspx" class="StaticMenuItemStyle">Services</a>
<br />
<div style="background-color: Blue; width: 180px;height: 5px;"></div>
</div>
</a>
</li>
但是 W3Validator 上的这个错误
Line 84, Column 63: document type does not allow element "div" here; missing one of
"object", "ins", "del", "map", "button" start-tag
style="color:Color [Blue];width:180px;">
The mentioned element is not allowed to appear in the context in which you've placed
it; the other mentioned elements are the only ones that are both allowed there and
can contain the element mentioned. This might mean that you need a containing
element, or possibly that you've forgotten to close a previous element.
One possible cause for this message is that you have attempted to put a block-level
element (such as "<p>" or "<table>") inside an inline element (such as "<a>",
"<span>", or "<font>").
但是,如果我用它验证的跨度替换 DIV。但看起来不对。有人知道如何解决这个问题吗?