TransWikia.com

How to center align the label text inside the option tag?

Stack Overflow Asked by Mr. Spock on January 11, 2021

I have the label text aligned in the left side and I would like to have it in the center. I’ve tried an id inside the option tag with "align text", "margin" and "padding" but it doesn’t work.

enter image description here

Here is my code:

<select id="primeiroselect"> 
  <option id="teste" label="Volvo">Volvo (Latin for "I roll")</option>
  <option label="Saab">Saab (Swedish Aeroplane AB)</option>
  <option label="Mercedes">Mercedes (Mercedes-Benz)</option>
  <option label="Audi">Audi (Auto Union Deutschland Ingolstadt)</option>
</select>

One Answer

Try this, it is center for choosen value, add select tag style="text-align-last:center"

<select id="primeiroselect" style="text-align-last:center";> 
 <option id="teste" label="Volvo">Volvo (Latin for "I roll")</option>
  <option label="Saab" align="center">Saab (Swedish Aeroplane AB)</option>
  <option label="Mercedes">Mercedes (Mercedes-Benz)</option>
  <option label="Audi">Audi (Auto Union Deutschland Ingolstadt)</option>
</select>

Answered by mikbal can on January 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP