Cascading Style Sheet (CSS) is a language which defined some formatting rule for html control. CSS are a collection of formatting rules that control the appearance of content in a web page. CSS apply in our application by following types:

External Style sheet

We use files and defined the CSS property and values in file and save it by .css extension. We use the css file in our project by link tag in head section

For example

<head runat="server"> 
            <link href="StyleSheet.css" rel="stylesheet" type="text/css"/>

Internal Style Sheet

Internal style sheet defined in head section by using the style tag

For example
<style type="text/css">
           body{color:Gray; font-size:small; }
Inline Style Sheet
Inline style sheet are used as
For example:
<asp:TextBox ID="TextBox1" runat="server" style="border:solid 1 red;"></asp:TextBox> 

Note: In inline style we use the style properties of the control set the value. In internal and external style sheet we apply the CSS on control by using the class properties for html control like <div class=”div1”>. And for the asp control we use the cssclass property for that control.

CSS ID and Class

CSS allows you to specify your own selectors called "id" and "class".

The Id selector is defined for a single, unique element basically for control or tag id. It is defined with # sign

For example

<div id=”div1”>Heloworld</div>

#div1{ color:Red;}

The class selector is used to specify a style for a group of elements and it is defined with dot symbol.

For example


And apply it as <p class=”p1”>This is the class selector</p>


  Modified On Sep-18-2014 01:23:53 PM

Leave Comment