HTML and CSS: Insert span into Option Select

Asked

Viewed 716 times

0

I’m trying to do the following Select:

Span dentro da Option Select

I tried to do it this way, but I couldn’t:

HTML:

<select class="form-control">
    <option>
        <a title="Alimentação">
            <span class="color" style="display: block; width:20px; height: 20px; background-color: rgb(255, 153, 0);"></span>
            <span class="label">Alimentação</span>
        </a>
    </option>
    ...
</select>

Thus appeared only the text, the color did not.

  • 2

    You cannot have HTML within option. You will have to build your own select from scratch with js

  • Exactly: https://html.spec.whatwg.org/multipage/forms.html#the-option-element

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.