Home > Enterprise >  Is <img> tag allowed inside <li> in Semantic HTML?
Is <img> tag allowed inside <li> in Semantic HTML?

Time:10-31

whicth tag are allowed inside the li tag?

div?
img?
span?
a (href)?

I think div is not allowed. But img, span and a are allowed. Am I right?

CodePudding user response:

Every tag is allowed. I tested in Firefox: img, span, a, even the div.

CodePudding user response:

You actually can put pretty much any of them inside a li. But different person has different opinion. Some will disagree with putting a div inside a list item, but according to the W3C validator you actually can do that. But still, if you need to check or need to use nested elements, you can use W3C validator or any other tools available online.

<ul>
   <li>
      <span>Some text</span>
   </li>
    <li>
      <p><a href="#">link</a></p>
   </li>
    <li>
      <img  width="150" height="150" src="https://images.unsplash.com/photo-1633114127451-558041183c3b?ixid=MnwxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=870&q=80" alt="alt" />
   </li>
   <li>
      <div>
       <input type = "text" />
      </div>
   </li>
</ul>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>

CodePudding user response:

You can use every tag you want.

  • Related