CSS

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

CSS -

HTML / Server Control ->

Style attribute -> control level / tag level ->in line

ex.

<asp:Button ID="Button1" runat="server" Text="Home" style="background-


color:red;color:white;" />
&nbsp;<asp:Button ID="Button2" runat="server" Text="About Us" style="background-
color:blue;color:white;" />

Page Level Style -

ex. of class Selector

<head>

<style type="text/css">

.buttonStyle1
{
background-color:black;
color:yellow;
width:100px;
border:double;
border-radius:10px;
}

.headingStyle1
{
background-color:blue;
color:yellow;
border:double;
border-radius:10px;
}

</style>

</head>

Note:
1. the class can be defined using the . symbol followed by any meaniningful name

2. to apply the class in Server control use the CssClass attribute i.e.

<asp:Button ID="Button1" runat="server" Text="Home"


CssClass="buttonStyle1" />

3. To apply the class in the html tag use the class attribute

<h2 class="headingStyle1">Example of CSS</h2>

External CSS -

Project->Add New Item->StyleSheet->Add


To link -

<link href="StyleSheet1.css" rel="stylesheet" type="text/css"/>

Tag Selector - it is created for specific tag only

it is automatically appiled to the given tag

ex. of Tag Selector

h1 {
background-color: black;
color: yellow;
border: double;
border-radius: 10px;
}
h2 {
background-color: yellow;
color: black;
border: double;
border-radius: 10px;
}
body
{
background-color:cyan;
}

27/09/21

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs"


Inherits="WebApplication38.WebForm2" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>

<style type="text/css">

/*iD Selector*/
#homebutton
{
background-color:blue;
color:white;
}
/*Group Selector*/
h1,h2,h3
{
color:blue;
}
/*contextual selector*/
p em
{
color:blue;
}
/*compound selector*/
#homebutton:hover
{
background-color:black;
color:yellow;
border-radius:10px;
}
/*attribute Selector*/
input[type="Text"]
{
background-color:white;
}
input[type="Text"]:hover
{
background-color:yellow;
}

</style>
</head>
<body>
<form id="form1" runat="server">

<p> For details Visit <em> www.abc.com </em></p>


username:<input type="text" />
<br />
pasword: <input type="text" />
<br />
<input type="submit" value ="Submit" id="submit" />
<input type="reset" value="Clear" id="clear" />

<em>Thanks</em>
</form>
</body>
</html>

You might also like