There is no attribute like input's placeholder for select box dropdown.
However, you can create similar effect by using the HTML disabled and selected attribute on a <option> element that has empty value. You can also apply the attribute hidden, which hides the placeholder option once selection is made in the dropdown.
Now, let's try out the following example to understand how it basically works:
The hidden attribute do not supported in Internet Explorer 10 and below. If you need to support IE10 and lower you can alternatively use the CSS option[disabled]{ display: none; }.
Use the
disabledandselectedAttributeThere is no attribute like input's
placeholderfor select box dropdown.However, you can create similar effect by using the HTML
disabledandselectedattribute on a<option>element that has empty value. You can also apply the attributehidden, which hides the placeholder option once selection is made in the dropdown.Now, let's try out the following example to understand how it basically works:
The hidden attribute do not supported in Internet Explorer 10 and below. If you need to support IE10 and lower you can alternatively use the CSS option[disabled]{ display: none; }.
need an explanation for this answer? contact us directly to get an explanation for this answer