I'm attempting to underline part of the text in an input field only using CSS.
I can underline the entire option by adding the text-decoration: underline to the select element like so:
.underline {
text-decoration: underline;
}
<select name="id" id="products" class="underline">
<option value="val1">my value 1</option>
<option value="val2">my value 2</option>
<option value="val3">my value 3</option>
</select>
I tried wrapping a span tag on the innerText of the option element text I'm interested in and adding the same class to the span element..
<select name="id" id="products">
<option value="val1">my <span class="underline">value 1</span></option>
<option value="val2">my <span class="underline">value 2</span></option>
<option value="val3">my <span class="underline">value 3</span></option>
</select>
.. but this doesn't have the desired effect as it seems you can't style option elements.
Is there a way to achieve this without using Javascript?