首页 > 解决方案 > 在此上下文中,元素 h3 不允许作为元素标签的子元素。[html]

问题描述

我目前有这个代码:

<ul class="char">
            <li>
            <label class="textOverImage" style="background-image:url(img/text.png)">
               <input type="checkbox">
               <h3>Joyce Byers</h3>
               <div>
               text
               </div>
            </label>
            </li>   

w3.validator.org 给了我这个错误:在这种情况下不允许元素 h3 作为元素标签的子元素。

在此上下文中,不允许元素 div 作为元素标签的子元素。

我真的不知道另一种方法可以做到这一点。有没有办法在没有错误的情况下得到我想要的东西?

我正在尝试这样做:https ://codepen.io/zFunx/pen/QvzeBN

谢谢你的好处

标签: html

解决方案


您可以使用以下场景之一:

<label for="username-input">Username</label>
<input type="text" name="username" id="username-input">

<!-- Or, if you want the input inside of the label -->
<label>
<span>Username</span>
<input type="text" name="username">
</label>

你可以在这个线程中找到更多信息


推荐阅读