Cascaded Style Sheet(CSS)

Cascaded Style Sheets (CSS) in ASP.NET Web applications
Understanding CSS
Ø  CSS stands for Cascaded Style Sheet.
Ø  CSS is used to apply common feel and look for your web application.
Ø  Styles define how to display html elements.

Advantages of using CSS
Ø  It gives uniform look and feel to web application
Ø  Ease of maintenance

There are Three way, Applying CSS to asp.net web application
                   OR
There are Three type of css

1.    External Style Sheets

2.    Internal Style Sheets

3.    Inline Style Sheets


External Style Sheets (Way –I)
 Ø  You can edit all your pages easier & reuse your CSS.
 Ø  Your page can load faster & easier.
 Ø  Save Space as well as Time.
 Ø  External style sheets keep your website design & content separate.
Applying CSS to asp.net web application
             Applying CSS is easy, Firstly Add new Folder-àGive Name AS (CSS)
             1)Right Click on CSS Folder---à2)Add New Item--à
       3)new wizard open(Add New Item)--àStyle Sheet.css--à4)ok ,as show below
    

Now copy and paste the .CSS Content, example

/*To apply to following style to all Paragraph Tag.*/
p
{
color:Purple;
font-size:xx-large;
font-family:Bookman Old Style;
background-color:Lime;
}
/*To apply to following style to all Heading1 Tag.*/
h1
{
color:Green;
background-color:Silver;
font-family:Comic Sans MS;
}
/*Let say, I want to apply a specific style to Paragraph Tag to some Page3 in my Web Application, you can do this using "class" attribute of Paragraph Tag, here you need to apply <p class="pForMyPage3">.*/
.pDefaultPage3
{
color:Gray;
font-size:xx-large;
font-family:Arial;
background-color:Yellow;
}
 /*for button */
.TestStyle1
     {
     font: 12pt verdana;
     font-weight:700;
     color:orange;
     }
.TestStyle2
{
      font: 12pt verdana;
     font-weight:900;
     color:Maroon;
}
Step2: Adding content to .CSS File

Step 3: Adding .CSS File Link into .aspx Page

See below figure for knowing how to apply CSS to control and adding link tagS.


OUTPUT:-






Internal Style Sheets  (Way –II) Applying CSS to asp.net web application
Internal style sheets are defined by using the <style> tag within the <head>area of the document. Here is an example of an internal style sheet as following:
<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">
    <title>Untitled Page</title>
    <%--WAY-II ADD CSS IN SOURCE CODE--%>
<style type="text/css">     
p
{
color:Purple;
font-size:xx-large;
font-family:Bookman Old Style;
background-color:Lime;
}
.TestStyle1
          {
          font: 12pt verdana;
          font-weight:700;
          color:orange;
          }
</style>

</head>
<body>
    <form id="form1" runat="server">
       <p>To apply to following style to all Paragraph Tag.</p>
        <br />
        <asp:Button  CssClass="TestStyle1" ID="Button1" runat="server" Text="Button" />   
    </form>
</body></html>

OUTPUT:-





Inline Style Sheets  (Way –III)
Let I take one example
The example shows how to change the color and the left margin of a paragraph(p):


OUTPUT





How To Comment CSS

Comments can also include meta information like as following:
/* ------------author--------------------*/
/*-----------date created---------------*/
/*------------copyright information-----*/

 

/* ----------------

    Header

------------------*/

/* ----------------

  Content

------------------*/

/* ----------------

  Footer

------------------*/

 


  

 Problem or We can say disadvantages with using .CSS File in Asp.NET Web Application
  You cannot apply CSS to some ASP.NET server controls.



To Overcome(Solution) .CSS File problem in Asp.NET  Web Application
      You can make use of Themes come to picture.

Tabs


Tab 1 content goes here

Tab 2 content goes here

Tab 3 content goes here
Multi-Tabbed Widget | DotNetIs