Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

text-align: right on <select> or <option>

Tags:

html

css

webkit

Does anyone know if it's possible to align text to the right of a <select> or more specifically <option> element in WebKit. This does not need to be a cross-browser solution including IE, but should be pure CSS if it is possible.

I have tried both:

select { text-align: right } and option { text-align: right }, but neither seems to have worked in WebKit (either Chrome, Safari or Mobile Safari.

Any help gratefully received!

like image 242
BenM Avatar asked Oct 27 '11 18:10

BenM


People also ask

How do I align selected text to the right?

Align a Paragraph To align left, press Ctrl + L. To align right, press Ctrl + R. To align center, press Ctrl + C. To justify, Ctrl + J.

Is it okay to align text to right?

Right alignment should be used sparingly at best, as right alignment isn't good for user experience and readability. There are some rare cases that it can actually make sense if used in low uses, like in this modern business letterhead example.


1 Answers

You could try using the "dir" attribute, but I'm not sure that would produce the desired effect?

<select dir="rtl">     <option>Foo</option>         <option>bar</option>     <option>to the right</option> </select> 

Demo here: http://jsfiddle.net/fparent/YSJU7/

like image 61
Frank Parent Avatar answered Oct 16 '22 12:10

Frank Parent