Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Validation Error: Element a not allowed as child of element ul in this context. (Suppressing further errors from this subtree.)

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">

code:

<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>
like image 537
user3453751 Avatar asked Mar 24 '14 01:03

user3453751


People also ask

Can Div be direct child of UL?

No. The only element that may be a child of <ul> is <li> .

What does start tag body seen but an element of the same type was already open mean?

An opening <body> tag has been found in an incorrect place. Check that it appears only once in the document, right after the closing </head> tag, and that the whole document content is contained within <body> and </body> tags.


1 Answers

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.

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.

like image 191
Jukka K. Korpela Avatar answered Sep 20 '22 05:09

Jukka K. Korpela