How to style an option selector

Asked

Viewed 162 times

-2

Good afternoon, you guys,

I’m looking for a way to style a select but I’m not getting it, and I’m also not getting material on the internet to do it, if you can help me thank you.

And the next one I want to put one part in bold and the other part leave normal like:

<select name="">
      <option value=""><strong>Nome</strong> - Nome</option>
      <option value=""><strong>Nome1</strong> - Nome1</option>
      <option value=""><strong>Nome2</strong> - Nome2</option>
</select>

The Strong or the b put like that doesn’t work.

1 answer

0

  • Would not have other ways to do that? my purpose is to leave only a part even independent of the way.

  • If it’s something really much needed I recommend using Select2, all modern javascript frameworks have better dropdown implementations, but pure HTML doesn’t allow customization

  • According to the documentation, the internal value within the option should be text only: https://html.spec.whatwg.org/multipage/form-elements.html#the-option-element

  • You can also use optgroup to make it more organized https://developer.mozilla.org/en-US/docs/Web/HTML/Element/optgroup

Browser other questions tagged

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