Below is my script for the drop down menu, how to make the text inside option value will have small front size ? I try to use span to make the front size but not working
<select name="metal-type" class="form-select form-select-lg" aria-label="Default select example" id="metalSelector">
<option value="au" selected>Gold <span front-size="10px;">(1gram - 0.243usb)<span></option>
<option value="ag">Silver <span front-size="10px;">(1gram - 0.200usb)<span></option>
</select>
How to make the text inside option value will have small front size ?
2
Answers
You are not able to do that with plain HTML and CSS. (At least not with Select and Option only)
You will have to introduce this behavior yourself.
The suggested way is to use a Frontend Framework like Bootstrap Accordions + JS or materials.
If you want to go the hard way, you may develop it your self.
Something like:
Span is not a valid element inside an option HTML element.
If you want a dropdown for which you can customize the options (since you tagged bootstrap-4) https://getbootstrap.com/docs/4.0/components/dropdowns/.
There are also other easy-to-use solutions like select2 which would work for your usecase (https://select2.org/getting-started/basic-usage).
You could also build it yourself, there are plenty of tutorials and examples eg like https://jssecrets.com/how-to-build-custom-javascript-select-dropdown/