验证错误:在这种情况下,元素a不允许作为元素ul的子元素. (抑制此子树中的其他错误.) [英] Validation Error: Element a not allowed as child of element ul in this context. (Suppressing further errors from this subtree.)

查看:59
本文介绍了验证错误:在这种情况下,元素a不允许作为元素ul的子元素. (抑制此子树中的其他错误.)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找到此验证错误的解决方案.我有一个带有缩略图的图像网格,单击该缩略图会弹出一个模态.一切正常,但无法验证.我不能在模态图像周围放li或单击之前显示它.我对编码还很陌生,任何帮助都会很棒.

I am trying to find a solution to this validation error. I have an image grid with thumbnails that bring up a modal when clicked. Everything works correctly but it does not validate. I can't put li around the modal image or it shows before clicked. I am pretty new to coding, any help would be great.

Line 54, Column 41: Element a not allowed as child of element ul in this context. 
(Suppressing further errors from this subtree.)

<a href="#_" class="lightbox" id="img10">

代码:

<ul class="cbp-rfgrid">
    <li>
        <a href="#img10"><img src="images/portfolio/goat-tn2.jpg" alt="logo"></a>
    </li>
    <a href="#_" class="lightbox" id="img10">
      <img src="images/portfolio/goat.jpg" alt="logo">
    </a>
</ul>

推荐答案

在任何版本的HTML中,ul的内容模型都不允许a子级.如果希望将a元素包含在ul元素中,则需要将其包装在ul元素中.

The content model of ul does not allow an a child, in any version of HTML. You need to wrap the a element inside an li element, if you wish to have it inside a ul element.

目前尚不清楚为什么首先使用ul.如果第二张图像最初不可见,那肯定完全取决于所涉及的样式表和脚本.由于尚未公开,因此无法说出应如何重写代码.

It is not clear why you are using ul in the first place. If the second image is not visible initially, that surely depends entirely on style sheets and scripts involved. As they have not been disclosed, it is impossible to say how you should rewrite the code.

这篇关于验证错误:在这种情况下,元素a不允许作为元素ul的子元素. (抑制此子树中的其他错误.)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆