I have a hidden element on my page with id select-box:
<select style="display:none;" id="select-box">
There's a <label> at the top of my page:
<label for="select-box">Select box</label>
Because the <select> is hidden, clicking on the <label> has no effect. Is there a way to achieve this, preferably without using any JavaScript?
The css feature display:none; removes the element from the document.
try:
style="visibility:hidden; width:0px"
visibility:hidden keeps the element in the dom and also takes up space so I've given a width of 0px to ensure no blank space will remain.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With