RobertD RobertD - 3 months ago 10
CSS Question

Hide select option before last CSS

I use this line to hide the last option in a select, I need only CSS:

.form-search > select option:last-child {display:none;}

how I can do to hide the previous option, the option that is before last?

Can be selected by value? for example the last has 55 value and the option before last has 54 value.
Thank you


You use nth-last-child(2).

Like this:

.form-search > select option:nth-last-child(2) { display:none; }

You can read more here:

This is supported in IE 9+, Chrome 4+, FF 3.5+, Safari 3.2+