结束标记a违反了嵌套规则



我在W3上验证了我的代码,但出现了这个错误,我不知道如何修复它。这是我的代码

<section class="flex">
    <a href="mug.html">
        <div class="img">
        <img src="images/img5mug1.jpg" alt="We are Infinite mug">
        We are Infinite mug
    </a>
</section>
<section class="flex">
    <a href="tshirt.html">
        <div class="img">
        <img src="images/img6tshirt1.jpg" alt="The Perks of Being a Wallflower t-shirt">
        The Perks of Being a Wallflower t-shirt
    </a>
</section>
<section class="flex">
    <a href="bag.html"><div class="img">
        <img src="images/img7bag1.jpg"  alt="The Perks of Being a Wallflower bag">
        The Perks of Being a Wallflower tote bag
    </a>
</section>
<section class="flex">
    <a href="cap.html"><div class="img">
        <img src="images/img8cap1.jpg" alt="The Perks of Being a Wallflower cap">
        The Perks of Being a Wallflower cap
    </a>
</section>

在每个a中,您打开但不是关闭一个具有类"img"的div。这可能于事无补。

另外,您使用的doctype是什么?HTML4.01不喜欢用a包装div,而HTML5应该可以(尽管我认为您使用的是HTML5,因为您的代码段包含section)。

最新更新