Everything except the actual function of hiding the div is working. The reason I need this without JavaScript is because it is a no JavaScript warning, that is able to be hidden. I am using CSS to try and set the div's display to none but I don't seem to be doing it right.
HTML
<noscript>
<div class="jswarning">
JavaScript is disabled. For the best experience, enable it.
<label class="jswarningbutton" for="hidejswarning">Hide</label>
<input id="hidejswarning" type="checkbox">
</div>
</noscript>
CSS
.jswarning {
box-sizing: border-box;
padding: 5px;
background:red;
width:100%;
color:white;
text-align:center;
}
.jswarningbutton {
background: white;
color: red;
cursor: pointer;
}
.jswarningbutton + input {
display: none;
}
.jswarningbutton + input[type=checkbox]:checked ~ .jswarning {
display: none;
}
:has(); which is part of the Web Baseline since December 2023: stackoverflow.com/a/78163570/633961