0

It is just me, or using CSS to specify the width of a SELECT element does not take effect (in IE at least)?

The only way I can get the width to apply is to set it like:

<select id="pageSizes" name="size" style="width: 45px">

My CSS is:

#pageSizes
{
    width: 45px
}
5
  • Working fine for me; jsfiddle.net/3nMjD Commented Jan 4, 2012 at 0:58
  • Works for me in IE 8. Are you missing something? Commented Jan 4, 2012 at 0:59
  • Likewise: jsfiddle.net/mattball/DG37r Commented Jan 4, 2012 at 1:00
  • To clarrify, setting width on element works, using CSS and no width on element doesn't. Commented Jan 4, 2012 at 1:03
  • <select id="pageSizes" name="size" style="width: 45px"> you're missing the semicolon in the style after 45px. Should look like <select id="pageSizes" name="size" style="width: 45px;"> Commented Jun 13, 2014 at 9:54

1 Answer 1

1

Works fine for me in IE9 and IE7 compatibility mode (fiddle):

<select id="pageSizes" name="size">
    <option>8.5" x 11"</option>
    <option>6" x 10"</option>    
</select>

css:

#pageSizes
{
 width:45px;   
}

[edit] Judging by the behavior you've described, wherein an inline-style achieves the desired result, you've probably got a conflicting css rule somewhere. So, show us all of your css.

Sign up to request clarification or add additional context in comments.

1 Comment

@xander-guerin Make sure you use the HTML5 DOCTYPE to throw IE into "Almost standards mode": <!DOCTYPE html>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.