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:

C# 8.0 and .NET Core 3.0 – Modern Cross-Platform Development: Build applications with C#, .NET Core, Entity Framework Core, ASP.NET Core, and ML.NET using Visual Studio Code, 4th Edition
ASP.NET Core 3 and Angular 9: Full stack web development with .NET Core 3.1 and Angular 9, 3rd Edition
C# in Depth, 4th Edition

 

<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>