.net dropdownlist align text

Dedrick picture Dedrick · Apr 17, 2009 · Viewed 9.6k times · Source

I am trying to align the text in my .net dropdownlist to the right. Using CssClass I am able to align text to the right in Firefox.

IE doesn't not align text to the right it aligns to the left. I have read that IE 6 doesn't support this.

  1. Is this true?

I am using IE7 but most of my users will be in IE 6 so, both need to work.

<asp:DropDownList ID="ddlNomination" Width="250px" CssClass="ddlnomination"
    runat="server" DataSourceID="Azoa" DataTextField="nomination_type" 
    DataValueField="nomination_type">
    <asp:ListItem> </asp:ListItem>
</asp:DropDownList>

css

.ddlnomination
{
   text-align:right;
}

Answer

scunliffe picture scunliffe · Apr 17, 2009

Setting it (text-align="right") on the Select or Option elements in IE6, IE7 & IE8 (even in standards mode) does not appear to work.

Some quick stats after testing.

Browser    |  Result
 Firefox 3     Passes
 Opera 9.5     Passes
 IE 6          Fails
 IE 7          Fails
 IE 8          Fails
 Safari 3      Fails
 Safari 4      Fails
 Chrome        Fails on the Option element, Passes on the Select element