简体   繁体   English

w3 html5 验证,锚点不允许作为 ul 的子项

[英]w3 html5 validation, anchor not allowed as child of ul

When I validate my html on w3 validator, I get the following error:当我在 w3 验证器上验证我的 html 时,出现以下错误:

Element a not allowed as child of element ul in this context.在此上下文中,元素 a 不允许作为元素 ul 的子元素。 (Suppressing further errors from this subtree.). (抑制来自该子树的更多错误。)。

The site is displaying properly (and the anchor is working) on my phone, tablet and desktop, and I don't really understand this error message.该网站在我的手机、平板电脑和台式机上正常显示(并且锚点正在运行),但我不太理解此错误消息。 Can somebody tell me what I did wrong and how to do this properly?有人可以告诉我我做错了什么以及如何正确地做到这一点吗?

Here's the part of the code that produces the error:这是产生错误的代码部分:

<section id="skills">
    <div class="skills-header">
        <p>Pozdravljen Svet! Pišem lahko:</p>
    </div>
    <div class="skills-container">
        <ul>
            <li>< html5 ></li>
            <li> { css3 }</li>
            <li>javascript.js</li>
            <li class="break">$(jQuery)</li>
            <li class="break"><%= rails 4 %></li>
            <li class="break">< div class="bootstrap" ></li>
            <li class="break">$ sudo apt-get update</li>
            <a href="https://si.linkedin.com/pub/miha-šušteršič/b2/60/654"><li class="profile-icon ion-social-linkedin"></li></a>
            <a href="https://github.com/Shooshte"><li class="profile-icon ion-social-github"></li></a>
        </ul>
    </div>
</section>

<ul> can only contain <li> elements. <ul>只能包含<li>元素。 It's as simple as that really.就这么简单。

<ul> is an "Unordered List", and an <li> is a "List Item". <ul>是“无序列表”, <li>是“列表项”。 A list should only contain list items...列表应该只包含列表项...

You may find it is working in your browser, but you shouldn't keep it that way.您可能会发现它在您的浏览器中正常工作,但您不应该保持这种状态。 Some browsers will auto-correct your error and wrap an <li> around your <a> elements, others will just make it look awful.一些浏览器会自动更正你的错误并在你的<a>元素周围包装一个<li> ,其他浏览器只会让它看起来很糟糕。

If you want to correct your code I suggest the following:如果你想更正你的代码,我建议如下:

<li><a href="https://si.linkedin.com/pub/miha-šušteršič/b2/60/654" class="profile-icon ion-social-linkedin"></a></li>
<li><a href="https://github.com/Shooshte" class="profile-icon ion-social-github"></a></li>

When I validate my html on w3 validator, I get the following error:当我在 w3 验证器上验证我的 html 时,出现以下错误:

Element a not allowed as child of element ul in this context.在此上下文中,元素 a 不允许作为元素 ul 的子元素。 (Suppressing further errors from this subtree.). (抑制来自此子树的更多错误。)。

The site is displaying properly (and the anchor is working) on my phone, tablet and desktop, and I don't really understand this error message.该网站在我的手机、平板电脑和台式机上正常显示(并且锚点正在运行),但我不太明白此错误消息。 Can somebody tell me what I did wrong and how to do this properly?有人能告诉我我做错了什么以及如何正确地做到这一点吗?

Here's the part of the code that produces the error:这是产生错误的代码部分:

<section id="skills">
    <div class="skills-header">
        <p>Pozdravljen Svet! Pišem lahko:</p>
    </div>
    <div class="skills-container">
        <ul>
            <li>< html5 ></li>
            <li> { css3 }</li>
            <li>javascript.js</li>
            <li class="break">$(jQuery)</li>
            <li class="break"><%= rails 4 %></li>
            <li class="break">< div class="bootstrap" ></li>
            <li class="break">$ sudo apt-get update</li>
            <a href="https://si.linkedin.com/pub/miha-šušteršič/b2/60/654"><li class="profile-icon ion-social-linkedin"></li></a>
            <a href="https://github.com/Shooshte"><li class="profile-icon ion-social-github"></li></a>
        </ul>
    </div>
</section>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM