If you want to use a stylesheet rule in a web page, you first need to link the page to the appropriate stylesheet. You can do this by adding a <link> element in the <head> section of your page. The <link> element references the file with styles you want to use. The next example allows the page to use styles defined in the file StyleSheet.css which is in the same folder as the web page:

 

<link href=”StyleSheet.css” rel=”stylesheet” type=”text/css” />

 

As a next step you can bind any static HTML element or control to your style rules. For example, if you want a label to use the heading2 format, set the Label.CssStyle property to heading2:

 

<asp:Label ID=”Label1″ runat=”server” Text=”Heading2 style example.”

CssClass=”heading2″></asp:Label>

 

When you want to apply a style to HTML markup, you should set the class attribute. In the next example a style is applied to a <div> element, which groups a paragraph of text:

 

<div class=”blockText” id=”paragraph” runat=”server” >

<p>blockText style example.</p>

</div>