Sometimes, we want to make HTML select read only.
In this article, we’ll look at how to make HTML select read only.
How to make HTML select read only?
To make HTML select read only, we disable all the select’s options.
For instance, we write
<select>
<option disabled>1</option>
<option selected>2</option>
<option disabled>3</option>
</select>
to disable the options we don’t want the user to select with the disabled attribute.
And we set the default option with the selected attribute.
Conclusion
To make HTML select read only, we disable all the select’s options.