Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide empty option value with css

Tags:

html

css

I have a select option html, i need to hide one of the options only with css without changing the html structure like adding more class or id.

here's the html structure:

<select id="net_terms_id" name="order[account][net_terms_id]" class="select admin__control-select">
       <option value>-Select Net Term-</option>
       <option value="Devtest">Devtest</option>
       <option value="15 Days Net">15 Days Net</option>
</select>

here's what i've done so far with the css:

#net_terms_id option:empty {display: none;}
#net_terms_id option[value=""] {display: none;}
like image 640
simple guy Avatar asked Jun 13 '26 05:06

simple guy


1 Answers

If you want to hide the empty option with just css you can try adding selected disabled hidden style='display: none' and that should do the trick.

<select id="net_terms_id" name="order[account][net_terms_id]" class="select admin__control-select">
       <option value selected disabled hidden style='display: none'>-Select Net Term-</option>
       <option value="Devtest">Devtest</option>
       <option value="15 Days Net">15 Days Net</option>
</select>
like image 77
BFunk Avatar answered Jun 17 '26 23:06

BFunk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!