Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set a default prompt when nothing selected for "select" using css

Tags:

html

css

Is it possible to set a default prompt when nothing is selected for select box using css? or is there an elegant way to deal with this other than

 <option>Select Here</option>?
like image 659
Norks Avatar asked Apr 13 '13 05:04

Norks


People also ask

How do I set the default option in select?

The default value of the select element can be set by using the 'selected' attribute on the required option. This is a boolean attribute. The option that is having the 'selected' attribute will be displayed by default on the dropdown list.

How do I change CSS options?

To change the selected option background-color CSS style, we can set the style attribute of the select and option elements. to set the whole select element to background color 009966 and color FFF . Then we override the the styles in the option elements with style="background: white; color: black;" .


1 Answers

Try this:

<select>
    <option value="" disabled>Select one--</option>
    <option value="someVal1">Option 1</option>
    <option value="someVal2">Option 2</option>
    <option value="someVal3">Option 3</option>
    <option value="someVal4">Option 4</option>
</select>
like image 114
Zachary Kniebel Avatar answered Sep 21 '22 11:09

Zachary Kniebel