Skip to main content
CSharpUniversity ASP.NET and C# lessons

The search runs entirely in your browser over the published lesson list.

Styling server controls with a stylesheet

A server control is not a mysterious object in the browser. It renders as ordinary markup, and that markup can be styled with a stylesheet like anything else.

Give a control a class

Markup
<asp:Button id="btnSave" runat="server"
    Text="Save" CssClass="actionButton" />
CSS
.actionButton {
    padding: 10px 16px;
    background: #2c5743;
    color: #ffffff;
    border: 0;
}

Why a stylesheet beats inline styling

  • One change updates every page that uses the class.
  • The markup stays about structure and the stylesheet stays about appearance.
  • You can restyle the whole site without touching a single page.
Look at the rendered output. Run the page and view the source the browser received. Seeing the real markup is the quickest way to understand how a control renders.

As the site grows you will add pages. That is adding a new page to the site.

New lessons by email

Leave your address and get a short note whenever a fresh lesson is published. No account needed and you can stop at any time.

Thank you. Your address has been noted in this browser session. Connect a mailing service to deliver the notes for real.