I’m working on a project where I find it convenient to include elements other than <li>
inside a <ul>
. Is this semantically correct and acceptable in HTML or should I make the elements start with <li>
?
I have below one list inside another one. The element I am trying to put has the tag <textarea>
.
Example:
<ul class="list">
<li class="category">what + how + who</li>
<ul class="subcategories">
<li>WHAT do we do?</li>
<textarea class="input"></textarea>
<li>HOW do we do it?</li>
<li>WHO do we serve?</li>
</ul>
</ul>
2
Answers
Neither
<textarea>
or<ul>
is a valid child of<ul>
.Valid children are as follows…
<li>
<script>
<template>
Yes, you can write
<ul>
tag inside<li>
tag.I have used this pattern when building a multilevel navbar, where I want to open a navbar on hover of a parent navbar item.
For using
<textarea>
you should wrap it into<li>
tag cuz, you can’t use<textarea>
directly under the<ul>
tag.After fixes :