Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

padding is not working in Safari and IE in select list

Tags:

html

css

Does any one know why my Safari is not taking padding in select lists? It's working fine in FF please tell me what to do. is there any issue with the doctype?

code:

<select style="padding-left:15px">
<option>male></option>
<option>female></option>
</select>

I'm using the following doctype;

<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
like image 965
Mayur Avatar asked Jun 03 '10 14:06

Mayur


People also ask

How do I add padding to Li tag?

You need to apply padding-left: 20px; to the ul. Add this to your css: . listing { padding-left: 20px; } .

How do you add padding to a list in HTML?

To create space between list bullets and text in HTML, use CSS padding property. Left padding padding-left is to be added to <ul> tag list item i.e. <li> tag. Through this, padding gets added, which will create space between list bullets and text in HTML.

Does auto work on padding?

auto is not a valid value for padding property, the only thing you can do is take out padding: 0; from the * declaration, else simply assign padding to respective property block.


2 Answers

Even though the W3 spec doesn't disallow padding in select boxes, for whatever reason webkit browsers (Safari, Chrome) don't support it. Instead, you can remove the padding-left and use text-indent instead, adding the same amount to your select box width.

From your example in your comment:

<select id="sexID" name="user[sex]" 
        style="border:1px solid #C1272D;
               width:258px; // 243 + 15px
               text-indent:15px;
               height:25px;
               color:#808080;">
like image 80
mVChr Avatar answered Nov 03 '22 06:11

mVChr


Use a combination of text-indent and line-height to create the illusion of padding. Works in Safari and Should work in IE as well.

<select style="text-indent:15px; line-height:28px;">
 <option>male</option>
 <option>female</option>
</select>
like image 40
GDiz Avatar answered Nov 03 '22 05:11

GDiz