Placeholder in a select

1

I'm using placeholder in my input text type and they work perfect, just that I have a select , in which I want to put a placeholder where it says "select an option", but it does not appear, Does anyone know if I can add it? and how can it be added? Thanks, regards

    
asked by Emanuel Mejia 26.10.2017 в 00:22
source

2 answers

3

You can add a first option disabled, and at the same time selected that serves to show an informative text:

 <select>
    <option disabled selected>Selecciona una opción</option>
    <option value="item 1">Item 1</option>
    <option value="item 2">Item 2</option>
    <option value="item 3">Item 3</option>
</select>
    
answered by 10.03.2018 / 18:01
source
2

In a select you can not add a placeholder , but what you can do is add a option with value empty indicating what you want to add in placeholder , like this:

<select>
        <option value="">Selecciona una opción</option>
        <option value="item 1">Item 1</option>
        <option value="item 2">Item 2</option>
        <option value="item 3">Item 3</option>
    </select>
    
answered by 26.10.2017 в 00:24