Coder 2
Coder 2

Reputation: 4881

Styling asp.net controls

I'm hoping someone can help me with this.

When I'm styling html components say all divs on the page I would add a CSS like:

div
{
  background-color:Red;
}

which works fine. However when it come to styling an asp.net control say a button I try:

button
{
  background-color:Red;
}

but this doesn't work. Could someone please tell me how you style these creatures?

Upvotes: 0

Views: 517

Answers (1)

Chris Van Opstal
Chris Van Opstal

Reputation: 37537

An asp.net button is actually an input element. So to style it you would use:

input { background-color: red; }

But that would style all input elements (text boxes, button, radio buttons, check boxes). To target just buttons you can use some CSS3:

input[type=button] { background-color: red; }

Or, you can just give all the buttons you want to style a class and do it that way:

<asp:Button runat="server" CssClass="red-button" />

.red-button { background-color: red; }

Upvotes: 6

Related Questions