Background color of the option tag | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Background color of the option tag

Hello. I would like to know, if it's possible to set background color of the <option> tag. I am making a form with priority selecting. Options are 1, 2, 3, 4 or 5. I want option 1 to have red background when selecting abd also when selected. Is there any way to do so? This is my program. It's written in my native language, but you don't need to understand it. https://code.sololearn.com/WNdAyQfHjVUZ/?ref=app

19th Jun 2018, 7:27 AM
Jan Štěch
Jan Štěch - avatar
2 Answers
+ 5
Hello, Jan Štěch ! To avoid creating a large form with switches or switches, you sometimes need to create a drop-down menu or a scrollable list. For these purposes, the <select> tag and the option tags enclosed in it are ideal (to define each option in the <select> form element). This article describes some of the methods for styling the <select> tag with css, and it also shows how to create and draw an arrow inside the <select> tag. Perhaps you need an article where the design of the select tag is done using jQuery. By default, the selection list will look like this: The first option The second option The HTML code of the above selection list: HTML <select> <option> First option </option> <option> Second option </option> </select> http://dnzl.ru/view_post.php%3Fid%3D151
19th Jun 2018, 8:06 AM
Alexander Sokolov
Alexander Sokolov - avatar
+ 2
background of option is default by your mobile, so can't be changed
19th Jun 2018, 8:43 AM
Sudarshan Rai
Sudarshan Rai - avatar