Skip to content

Instantly share code, notes, and snippets.

@shaik2many
Created March 30, 2016 21:17
Show Gist options
  • Save shaik2many/7cf3c4f2826d0ab7baf5502e9adb2adf to your computer and use it in GitHub Desktop.
Save shaik2many/7cf3c4f2826d0ab7baf5502e9adb2adf to your computer and use it in GitHub Desktop.
//http://jsfiddle.net/LXp4h/
<script>
select option {
color: black;
}
select option:first-child {
color: grey;
}
select.empty {
color: red;
}
/* Hidden placeholder */
select option[disabled]:first-child {
display: none;
}
</script>
Re-selectable placeholder<br />
<select>
<option value="" selected>Please select</option>
<option value="1">Item 1</option>
<option value="2">Item 2</option>
<option value="3">Item 3</option>
</select><br />
Hidden placeholder<br />
<select class="empty">
<option value="" selected disabled>Please select</option>
<option value="1">Item 1</option>
<option value="2">Item 2</option>
<option value="3">Item 3</option>
</select>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment