I was making a Menu that only appears when a checkbox
is checked. And to change the status of this checkbox
I need to click on label
of it, since input:checkbox
is actually hidden.
What happens is that within label
I put a button
, and thus I can not activate checkbox
... See that according to the documentation within label
all Phrasing_content
link
About Phrasing Content
Notice that here I have the codes, one that does not work with button
inside, and another one that works without button
.
So why does label
like button
not activate checkbox
?
li{
display: inline-block;
background-color: red;
}
nav {
display: none;
}
[type="checkbox"] {
display: none;
}
[type="checkbox"]:checked + nav {
display: block;
}
label {
cursor:pointer;
}
<label for="btnx"><button>button</button></label>
<input type="checkbox" name="" id="btnx">
<nav>
<ul>
<li>item 01</li>
<li>item 02</li>
<li>item 03</li>
</ul>
</nav>
<br><br>
<label for="btny">label</label>
<input type="checkbox" name="" id="btny">
<nav>
<ul>
<li>item 04</li>
<li>item 05</li>
<li>item 06</li>
</ul>
</nav>