Hitesh Gawhade
Hitesh Gawhade

Reputation: 181

How to Set DropdownList 1st element text in center and Keep Rest left aligned?

I have an asp dropdownlist, I have "Select Option" as the first element in dropdown. All elements in dropdown including 1st are aligned left automatically. If I set text-align to center, all the list items are getting aligned to center, which I dont want. I only need to set the 1st element (Header) of dropdown in center. How to do it ?

Upvotes: 1

Views: 895

Answers (1)

SurinderBhomra
SurinderBhomra

Reputation: 2199

You could add a CSS class to the first item in the drop down list on page load:

test.Items[0].Attributes["class"] = "header";

Then you can apply specific styles to the "header" class in your CSS file.

Upvotes: 2

Related Questions