Horizontal text center for option selection

I have this simple fiddle with a standard <select>html element , all I am trying to do is give center alignment for the tags <option>.

I already tried text-indent: 20pxbut its center is only the visible tag in select!

How can I center this?

+5
source share
4 answers

Solution 1: (simple solution)

select {
   ...    
   padding: 0 0 0 20px;
}

Demo 1

Solution 2: (added on 10/27/2017)
Only the selected number will be centered.

* Probably not yet supported by Safari

select {
   ...
   text-align: center;
   text-align-last: center;
}

Demo 2

+7
source

You can just use

select {
    text-align: center;
}

. JSFiddle

, Firefox. Chrome padding-left, @CTravel

select {
    padding-left: 20px;
}

JSFiddle

option Firefox, - .

+4

select {
   ...    
   padding: 0 0 0 20px;
}

select {
    text-align: center;
}

select. , JQuery: JQuery UI

+2

All Articles