CSS Class Notes
CSS Class Notes
Syntax of CSS:
<style type="text/css">
css code here
</style>
1 .Tag selector
==> The "Tag selector" selects all the instances of specific tag
==> Use tag selector to select multiple elements.
Syntax : tagname
Example : p
2 . Id Selector
==> The "id Selector" selects a single tag,based on the "id"
==> "ID" is the "identification name"; it must be unique
==> Use ID selector to select a exact single element.
<html>
<head>
<title> CSS --First Example </title>
<style type="text/css">
p
{
color:green
}
</style>
</head>
<body>
<p> This is HTML with CSS </p>
<p> Content of CSS </p>
</body>
</html>
Example on ID Selector
<html>
<head>
<title> CSS --ID Selector </title>
<style type="text/css">
#p3
{
color:blue
}
</style>
</head>
<body>
<p> Para 1 </p>
<p> Para 2 </p>
<p id="p3">para 3 </p>
<p> para 4 </p>
<p> para 5 </p>
</body>
</html>
CSS -- Properties :
color : This property specifies text color (font color) of the element
Syntax : color : colorname;
Ex : color : green;
Example on color Property
<html>
<head>
<title> CSS --Text Color </title>
<style type="text/css">
#p1
{
color : red
}
#p2
{
color : green;
}
#p3
{
color:blue;
}
</style>
</head>
<body>
<p id="p1"> Para [Link] many guides on the internet attempt to teach HTML
</p>
<p id="p2"> Para [Link] many guides on the internet attempt to teach HTML
</p>
<p id="p3"> Para [Link] many guides on the internet attempt to teach HTML
</p>
</body>
</html>
background-color
<style type="text/css">
#p1
{
color : red
background-color:pink;
}
#p2
{
color : green;
background-color:red;
}
#p3
{
color:blue;
background-color:pink;
}
</style>
</head>
Types of Colors
1 Named Colors
2 RGB
3 Hexadecimal Number
Named Colors :
==>We can write name of the color directly.
==> These are limited
==> We can't get exact shade of the color
==> Ex : white,green,black,orange etc
==> This are not recommended in real time
RGB :
RGB formula specifies that the composition of 3 basic colors(red,green,blue) generates 16
million colors
Syntax : rgb(red,green,blue)
==> Red = 0 to 255
==>Green = 0 to 255
==>Blue= 0 to 255
Example : rgb(0,0,0) = black
rgb(255,0,0) = red
rdb(0,255,0) = green
rgb(0,0,255)=blue
etc combinations
Hexadecimal Format :
==> "Hexadecimal format" is the shortcut of "RGB"
==> Hexadecimal Number system supports 16 symbols as
0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
==> Hexadecimal number should be 6 symbols long with'#' [Link] two symbols
represent red,second two symbols represent green, third two symbols represent blue.
Syntax : #redgreenblue
Example :
#ffffff = white
#000000 = black
#ff0000 = red
Note : Hexadecimal format is recommended in realtime
Example on Colors
<html>
<head>
<title> CSS -- Colors </title>
<style type="text/css">
#p1
{
background-color:pink;
}
#p2
{
background-color:rgb(240,250,160);
}
#p3
{
background-color:#6fecd3;
}
</style>
</head>
<body>
<p id="p1"> Para [Link] many guides on the internet attempt to teach HTML
</p>
<p id="p2"> Para [Link] many guides on the internet attempt to teach HTML
</p>
<p id="p3"> Para [Link] many guides on the internet attempt to teach HTML
</p>
</body>
</html>
Font-Styles
font-family
Syntax :
font-family : "fontname";
Ex : font-family : "Arial";
Note : It is recommended to specify multiple font family names ;If specified browser tries the
subsequent font if the previous font is not found/not supported in the browser
Ex :
<style type="text/css">
#p1
{
font-family:"Times New Roman";
color:#cc00ff;
background-color:#6fecd3;
font-size:12px;
font-weight:bold | normal
font-style:italic | normal
}
Text Styles
letter-spacing
==> This property specifies gap between letters. For Example in "ABC" ,the letter spacing
specifies gap between "A" and "B" and also gap between "B" and "C"
Syntax :
letter-spacing : pixels
Ex : letter-spacing : 10px
Word-spacing
Syntax :
word-spacing:pixels;
word-spacing:10px;
word-spacing:normal/-10px/5px
{
font-family:"Times New Roman";
color:#cc00ff;
background-color:#6fecd3;
font-size:40px;
font-weight:bold;
font-style:italic;
letter-spacing:-2px;
line-height:100px;
}
#p2
{
font-family:"Comic Sans MS" ;
background-color:rgb(240,250,160);
letter-spacing:-1px;
word-spacing:20px;
}
Syntax :
text-align: left|right|center|justify;
Ex :
text-align:center
text-indent
This property specifies the left margin For the First line in the paragraph.
Syntax :
text-indent: pixels
Ex :
text-indent:10px;
<html>
<head>
<title> CSS -- Colors </title>
<style type="text/css">
#p1
{
font-family:"Times New Roman";
color:#cc00ff;
background-color:#6fecd3;
font-size:5px;
font-weight:bold;
font-style:italic;
letter-spacing:20px;
line-height:100px;
text-decoration : underline;
text-transform : capitalize;
text-align : center;
}
#p2
{
font-family:"Comic Sans MS" ;
background-color:rgb(240,250,160);
letter-spacing:-1px;
word-spacing:20px;
}
#p3
{
font-family:"Black Monk"
background-color:#6fecd3;
letter-spacing:10px;
}
</style>
</head>
<body>
<p id="p1"> css </p>
<p id="p2"> Para [Link] many guides on the internet attempt to teach HTML
</p>
<p id="p3"> Para [Link] many guides on the internet attempt to teach HTML
</p>
</body>
</html>
Span
<span> represents a small amount of text,For which you can apply some special formatting .
<span> is a paired tag
<span> tag doesn't apply any style by default ,but we can applay any styles for it
Syntax
<span> Your Content here </span>
<html>
<head>
<title> CSS -- Span </title>
<style type="text/css">
#span1
{
color:hotpink;
font-weight:bold;
text-decoration : underline;
text-transform : capitalize;
}
#p1
{
font-family:"Black Monk"
background-color:#6fecd3;
letter-spacing:10px;
}
#p1
{
font-family:"Black Monk";
background-color:#6fecd3;
letter-spacing:5px;
}
</style>
</head>
<body>
<p id="p1"> You can find more information about how CSS Works
<span id="span1"> privacy policy </span> or additional terms for particular
services </p>
</body>
</html>
Background Image
Syntax : background-image:url("[Link]");
Ex :
<style type="text/css">
#p1
{
background-color:skyblue;
background-image: url('[Link]');
}
</style>
</head>
<body>
<p id="p1"> You can find more information about how CSS Works
</p1>
background-attachment
==> This property specifies whether the background image
should be scrolled along with the text,when the user uses the
scrollbars of the web page.
==>If the value is "scroll" the background image will be scrolled along with the text
==>If it is "fixed" the background will not be scrolled ,only the text will be scrolled.
Syntax : background-attachment:scroll|fixed
Ex :
#p1
{
background-color:skyblue;
background-image:url("[Link]");
background-attachment:fixed;
}
Lists
Ex : <html>
<head>
<title> CSS-Lists </title>
<style type="text/CSS">
#list1
{
list-style-type:square;
}
#list2
{
list-style-type:disc;
}
#list3
{
list-style-type:circle;
}
#list4
{
list-style-type:none;
}
</style>
</head>
<body>
<h3> UL -- Square </h3>
<ul id="list1">
<li> India</li>
<li> China </li>
<li> USA </li>
<li> UK </li>
</ul>
<h2> UL -- None </h2>
<ul id="list3">
<li> India</li>
<li> China </li>
<li> USA </li>
<li> UK </li>
</ul>
</body>
</html>
Syntax : list-style-type:none|decimal|decimal-leading-zero|
lower-alpha|upper-alpha|lower-roman|
upper-roman|lower-greek;
Ex : <html>
<head>
<title> CSS-Lists </title>
<style type="text/CSS">
#list1
{
list-style-type:lower-alpha;
}
#list2
{
list-style-type:upper-roman;
}
#list3
{
list-style-type:decimal-leading-zero;
}
#list4
{
list-style-type:lower-greek;
}
</style>
</head>
<body>
<h3> UL -- Square </h3>
<ul id="list4">
<li> India</li>
<li> China </li>
<li> USA </li>
<li> UK </li>
</ul>
<h2> UL -- None </h2>
<ul id="list2">
<li> India</li>
<li> China </li>
<li> USA </li>
<li> UK </li>
</ul>
</body>
</html>
list-style-image
=>This property specifies bullet image File path For the list
Syntax : list-style-image:url("[Link]")
Ex :
<html>
<head>
<title> CSS-Lists </title>
<style type="text/CSS">
#list1
{
list-style-image:url("[Link]");
}
</style>
</head>
<body>
Top Browsers
<ul id="list1">
<li> Google Chrome </li>
<li> Mozilla FireFox</li>
</ul>
</body>
</html>
<html>
<head>
<title> CSS-Lists </title>
<style type="text/CSS">
#list1
{
list-style-image: url("[Link]");
background-image: url("[Link]");
background-size: 16px 16px;
background-repeat: no-repeat;
background-position: 0 5px;
padding-left: 25px;
}
</style>
</head>
<body>
Top Browsers
<ul id="list1">
<li> Google Chrome </li>
<li> Mozilla FireFox</li>
</ul>
</body>
</html>
DIV
==> <div> tag is the important tag of html
--> It is a container in which you can place any other elements
==>A Web page can have any no: of <div> tag
==> A <div> tag can be placed in another <div> tag
==> <div> is a block level [Link] means it occupies 100% of the width by [Link] the
content next to the <div> tag appears in next line
Examples :
float :
==>This property displays the elemens side-by-side
==> If the value is "left" the elements will be displayed side by side starting left towards
right
==> If the value is "right" the elements will be displayed side by side from right towards
"left"
Syntax : float : left|right
clear :
==>This property cancels the effect of "float" and push the current element to next line .
==> It stops the sequence of "float"
==> Top stop "float:left" sequence we use clear:left
==> Top stop "float:right" sequence we use clear: right
Syntax :
clear:left|right;
#div3
{
background-color:#0044cc;
width:200px;
height:200px;
clear:left;
}
BOX Model
border-style
==> This property specifies type of border,around the element
==> default value is "none"
==> "solid" is recommended
Syntax : border-width:pixels;
Example on border
<html>
<head>
<title> CSS-Border With Box Model </title>
<style type="text/CSS">
#div1
{
background-color : #00ffcc;
width:200px;
height :200px;
float : left;
border-style:inset;
border-width:5px;
border-color:red;
}
#div2
{
background-color : #cc33ff;
width:200px;
height :200px;
float : left;
border-style:outset;
border-width:5px;
border-color:green;
}
</style>
</head>
<body>
<div id="div1">This is a Broder Property defined in the box model </div>
<div id="div2">This is a Broder Property defined in the box model </div>
</body>
</html>
border-shortcut
border -sides
"border-top" property
This Property specifies border width,border style and border color For top side
only
Syntax :
border-top: borderwidth borderstyle bordercolor;
#div1
{
background-color : #00ffcc;
width:200px;
height :200px;
float : left;
border-left:10px solid red;
border-top:10px solid #00ee22;
}
#div2
{
background-color : #cc33ff;
width:200px;
height :200px;
float : left;
border-top:10px solid green;
border-right:10px solid darkblue;
}
</style>
</head>
<body>
<div id="div1">This is a Broder Property defined in the box model </div>
<div id="div2">This is a Broder Property defined in the box model </div>
</body>
</html>
Margin
this property specifies the margin(gap) between element to element surrounding
the element.
For Ex If two <div> tags are display side-by side the gap between them is called as
margin
<html>
<head>
<title> CSS-Border With Box Model </title>
<style type="text/CSS">
body
{
text-align:justify;
}
#div1
{
background-color : #00ffcc;
width:200px;
height :200px;
float : left;
border-left:10px solid red;
border-top:10px solid #00ee22;
margin:10px 20px 20px 5px; //margin short form followed direction top right
bottam left
}
#div2
{
background-color : #cc33ff;
width:200px;
height :200px;
float : left;
border-top:10px solid green;
border-right:10px solid darkblue;
margin:10px 40px 20px 1px;
}
</style>
</head>
<body>
<div id="div1">This is a Broder Property defined in the box model </div>
<div id="div2">This is a Broder Property defined in the box model </div>
</body>
</html>
margin-sides
<!DOCTYPE html>
<html>
<head>
<title>Box Model</title>
<style type="text/css">
body //tag selector
{
text-align:justify;
}
Padding : specifies the padding(gap) between border and content of the element .Inner Margin is
called Padding .Outer margin is called as "margin"
Syntax : padding : pixels
"opacity" property
==>This property makes the element transparent (background information is visible through the
element)
==>you can specify any number between 0 to 1
==>Any middle number between 0 and 1 is recommended
Syntax :
opacity: 0 to 1;
1 : Fully visible
0.9 ....,0.1 : transparent
0 : invisible
Example
<html>
<head>
<title> CSS-Border With Box Model </title>
<style type="text/CSS">
body
{
text-align:center;
background-image:url("[Link]");
}
#div1
{
font-size:40px;
font-family:"Tahoma";
height:200px;
width:300px;
background-color:#009966;
opacity:0.5;
}
</style>
</head>
<body>
<div id="div1">INDIAN TEAM ICC Tropy INDIAN TEAM ICC Tropy INDIAN TEAM ICC
Tropy INDIAN TEAM ICC Tropy INDIAN TEAM ICC Tropy INDIAN TEAM ICC Tropy </div>
</body>
</html>
The css styles are defined inside the ".html" file itself
Syntax :
<style type="text/css">
css code
</style>
External Style Sheet:
==> The CSS styles are defined in a seperate ".css" file and html tags are defined in the
.html file
==> We can link (connect) the CSS file with html file
Advantages : It supports re-usability That means the css file can be called in many html files
h1
{
font-family:"Tahoma";
font-size : 25px;
color:green;
background-color:#002244;
color:yellow;
}
[Link]
<html>
<head>
<title> CSS--External Style--Page 1 </title>
<link href="[Link]" rel="StyleSheet">
</head>
<body>
<h1> Hello </h1>
</body>
</html>
[Link]
<html>
<head>
<title> CSS--External Style--Page 2 </title>
<link href="[Link]" rel="StyleSheet">
</head>
<body>
<h1> Hai </h1>
</body>
</html>
==> This CSS style sheet will be defined inside the html tag itself
==> This is NOT recommended in realtime
Drawbacks :
a) HTML code will be confusing
b) No -style reusability
Syntax :
<tag style="property:value; property:value;...">
</tag>
Ex :
<html>
<head>
<title> CSS--Inline CSS </title>
</head>
<body>
<p style="background-color:cyan font-size=40px">para 1 </p>
<p style="background-color:cyan font-size=40px">para 2 </p>
</body>
</html>
CSS Selectors
==>First we have select the element/elements and then only we can apply some styles to it.
==>"selector" is a "syntax to select" .It is used to select the desired elements in the web page.
==> When we use a selector the browser searches the entire web page For the matching elements
and returns the matching elements and we applystyles only for those matching elements .
1 .Tag selector
==> The "Tag selector" selects all the instances of specific tag
==> You can specify any tag name
==> Use tag selector to select multiple elements.
Syntax : tagname
Example : p
<html>
<head>
<title> CSS --Tag Selector </title>
<style type="text/css">
p
{
color:green;
background-color:skyblue;
}
</style>
</head>
<body>
<p> This is HTML with CSS </p>
<p> Content of CSS </p>
</body>
</html>
2 . Id Selector
==> The "id Selector" selects a single tag,based on the "id"
==> "ID" is the "identification name"; it must be unique
==> Use ID selector to select a exact single element.
==> Id should be unique in the web page .
Example on ID Selector
<html>
<head>
<title> CSS --ID Selector </title>
<style type="text/css">
#p3
{
color:blue
}
</style>
</head>
<body>
<p> Para 1 </p>
<p> Para 2 </p>
<p id="p3">para 3 </p>
<p> para 4 </p>
<p> para 5 </p>
</body>
</html>
Class Selector
==> It selects one or more elements based on the class name .
==> We use same class For similar elements
==> "." is the symbol For class Selector
Syntax : .class
Ex : .c1
Example
<html>
<head>
<title> CSS- Class selector </title>
<style type="text/CSS">
.c1
{
background-color : skyblue;
}
</style>
</head>
<body>
<h1> Class Selector </h1>
<p> para 1 </p>
<p class="c1"> para 2 </p>
<p> para 3 </p>
<p class="c1"> para 4 </p>
<p> para 4 </p>
<p class="c1"> para 6 </p>
<p class="c1"> para 7 </p>
</body>
</html>
Compound Selector
Example
<html>
<head>
<title> CSS- Compound selector </title>
<style type="text/CSS">
/* selecting only <p> tags that have class="class1" */
p.class1
{
background-color : skyblue;
}
</style>
</head>
<body>
<h1> Compound Selector </h1>
<p> para 1 </p>
<p class="class1"> para 2 </p>
<p> para 3 </p>
<p class="class1"> para 4 </p>
<p> para 5 </p>
<p class="class1"> para 6 </p>
<input type="text">
<input type ="text" class="class1">
<input type="text">
<input type="text" class="class1">
</body>
</html>
===> Need to apply For Text Boxes also Compound Selector check it
<html>
<head>
<title> CSS- Compound selector </title>
<style type="text/CSS">
/* selecting only <p> tags that have class="class1" */
p.class1
{
background-color : skyblue;
}
input[type="text"].class1 {
background-color: skyblue;
}
</style>
</head>
<body>
<h1> Compound Selector </h1>
<p> para 1 </p>
<p class="class1"> para 2 </p>
<p> para 3 </p>
<p class="class1"> para 4 </p>
<p> para 5 </p>
<p class="class1"> para 6 </p>
<input type="text">
<input type ="text" class="class1">
<input type="text">
<input type="text" class="class1">
</body>
</html>
Grouping Selector
Syntax : tag1,tag2,tag3,....
Ex : div,p,h3
Example
<html>
<head>
<title> CSS- Grouping selector </title>
<style type="text/CSS">
/* selecting all <h1> and all <p> tags*/
h1,p,input,span
{
background-color : skyblue;
}
</style>
</head>
<body>
<h1> Grouping Selector </h1>
<p> para 1 </p>
<p class="class1"> para 2 </p>
<p> para 3 </p>
<p class="class1"> para 4 </p>
<p> para 5 </p>
<p class="class1"> para 6 </p>
<input type="text" value="hello">
<input type ="text" value="hello" class="class1">
<input type="text" value="hello" class="class1">
<span> span 1 </span>
<span> span 2 </span>
</body>
</html>
Note : For all examples i need a website where there are using specific web sites open it and show
Example
<html>
<head>
<title> CSS- Child selector </title>
<style type="text/CSS">
/* selecting <p> which are children of <div>*/
div p
{
background-color : skyblue;
}
</style>
</head>
<body>
<h1> Child Selector </h1>
<div id="div1">
<p> para1 </p>
<p> para2 </p>
<p> para3 </p>
<p> para4 </p>
</div>
<p> para5 </p>
<p> para6 </p>
</body>
</html>
Example
<html>
<head>
<title> CSS- Direct Child selector </title>
<style type="text/CSS">
div>p
{
background-color : skyblue;
}
</style>
</head>
<body>
<h1> Direct Child Selector </h1>
<div id="div1">
<p> para1 </p>
<p> para2 </p>
<p> para3 </p>
<p> para4 </p>
<b>
<p> para5 </p>
<p> para6 </p>
</b>
</div>
<p> para7 </p>
</body>
</html>
Attribute selector :
It selects all the tags that are having specified attribute
"[ ] " are the symbols of attribute selector
We can use any attribute of any html tag
Syntax : tag[attribute="value"]
Ex : img[width="120px"]
Example
<html>
<head>
<title> CSS- Attribute selector </title>
<style type="text/CSS">
/* selecting element based on the attribute value*/
img[width='120px']
{
border : 4px solid red;
}
</style>
</head>
<body>
<h1> Attribute Selector </h1>
<img src="[Link]" width="120px">
<img src="[Link]" width="100px">
<img src="[Link]" width="120px">
<img src="[Link]" width="100px">
</body>
</html>
Note : which one specifies width 120 that jpg files effext with border what we specify
<html>
<head>
<title> CSS- Attribute selector </title>
<style type="text/CSS">
input[type="text"]
{
border: 4px solid blue;
padding : 10px;
}
a[target="_blank"]
{
color: red;
text-decoration : underline;
}
</style>
</head>
<body>
<h1> Attribute selector </h1>
Hover Selector
==> It applies the style only when the user places te mouse pointer on the element
at run time
==> It automatically removes the styles ,if the mounse pointer is moved outside
the element
==>It is also called as "Pseudo class" whenever the seelctor starts with ":" it is
called as "Pseudo class"
==> pseudo=unrealistic
Syntax : tag:hover
Ex : p : hover
Example
<html>
<head>
<title> CSS- Hover selector </title>
<style type="text/CSS">
p
{
background-color:skyblue;
}
p:hover
{
background-color:hotpink;
}
</style>
</head>
<body>
<h1> hover Selector </h1>
<p> para 1 </p>
<p> para 2</p>
<p> para 3</p>
<p> para 4</p>
</body>
</html>
Focus Selector
==> It applies the style only when the focus (cursor) is iniside the element
==> It automatically removes the style when the cursor gets out the element
==> It is also called as "Pseudo class"
Syntax : tag:focus
Ex : input:focus
Example
<html>
<head>
<title> CSS- Focus selector </title>
<style type="text/CSS">
input:focus
{
border: 4px dotted red;
}
</style>
</head>
<body>
<h1> Focus Selector </h1>
<input type="text"><br>
<input type="text"><br>
<input type="text"><br>
<input type="text"><br>
<input type="text"><br>
<input type="text"><br>
</body>
</html>
Universal Selector : ==> It selects all the tags in the web page (including <html> ,<head>,<body>
etc)
==> Used to apply global Styles
Syntax : *
Ex : *
<html>
<head>
<title> CSS- Universal selector </title>
<style type="text/CSS">
/* select all tags in the web page*/
*
{
font-family :"Segoe UI";
/*border: 4px dotted red;*/
}
</style>
</head>
<body>
<h1> Universal Selector </h1>
<p> para 1 </p>
<input type="text"><br>
<input type="text"><br>
<input type="text"><br>
<input type="text"><br>
</body>
</html>
==> The css styles are applied in the following order(lowest priority to highest priority)
==>The higher priority style overrides the same property's value of the lower priority
1 Browser default style
2 Tag selector
3 Direct child Selector
4 Child Selector
5 Class selector
6 Attribute selector
7 ID selector
Note : !important" is used to override the "style precendence"
Example
<html>
<head>
<title> CSS- Precendence </title>
<style type="text/CSS">
p
{
color:blue;
}
div>p
{
color:red;
}
.c1
{
color:green;
}
#p1
{
color:pink;
}
</style>
</head>
<body>
<div>
<p id="p1" class="c1"> Para 1 </p>
</div>
</body>
</html>
Output will be highest selector ie Tag selector --so output in pink color
If we add !important to any selector then the selector the color will occurs
For Example
<style type="text/CSS">
p
{
color:blue !important;
}
Then tag selector will effected first irrespective of order.
CSS Realtime Examples
Table Styles
<html>
<head>
<title> CSS With Table Styles </title>
<style type="text/CSS">
#table1
{
background-color:#003399;
font-size :30px;
font-family:'Tahoma';
}
#table1 tr
{
background-color:#33ccff;
}
#table1 tr:nth child(1)
{
background-color:#ff0099;
}
#table1 tr td
{
padding:5px;
}
#table1 tr th
{
padding:10px;
}
#table1 tr:hover
{
background-color:#00ffcc;
cursor:pointer;
}
</style>
</head>
<body>
<table id ="table1">
<tr>
<th> Name </th>
<th> Email </th>
</tr>
<tr>
<td> Scott </td>
<td> scott@[Link]</td>
</tr>
<tr>
<td> Allen </td>
<td> allen@[Link]</td>
</tr>
</table>
</body>
</html>
Example
<html>
<head>
<title> CSS Links </title>
<style type="text/CSS">
/* unvisited */
a:link
{
background-color:darkgreen;
font-size: 20px;
color:white;
padding:2px;
text-decoration:none;
font-weight: bold;
}
a:hover /* mouse over link*/
{
background-color:yellow;
color:darkgreen;
text-decoration : underline;
}
/* selected link*/
a:active
{
background-color:red;
color:cyan;
}
/* visited link*/
a:visited
{
background-color:black;
color:pink;
}
</style>
</head>
<body>
<a href ="[Link]
<a href ="[Link]
<a href ="[Link]
</body>
</html>
MenuBar
Menubar is a collection of hyperlinks arrange vertically/horizontally.
Example:
<html>
<head>
<title> CSS Links </title>
<style type="text/CSS">
.menubar
{
background-color:#00ffcc;
height:40px;
font-size:24px;
font-family:'Tahoma';
width:800px;
margin:auto;
}
.menubar ul
{
list-style-type:none;
padding:0px;
}
.menubar ul li
{
display:inline;
width:200px;
float:left;
height:40px;
text-align:center;
}
.menubar ul li a
{
line-height:40px;
text-decoration:none;
}
.menubar ul li:hover
{
background-color:#33cc99
cursor:pointer;
text-decoration:underline;
}
</style>
</head>
<body>
<div class="menubar">
<ul>
<li> <a href="#"> Home </a></li>
<li> <a href="#"> About </a></li>
<li> <a href="#"> Contact </a></li>
<li> <a href="#"> Services </a></li>
</ul>
</div>
</body>
</html>
Login Form
<div class="c1">
<div class="c3">
<label for="txtPassword"> Password : </label>
</div>
<div class="c4">
<input type="password" id="txtPassword" name="password">
</div>
</div>
<div class="c2">
<input type="checkbox" id="chkremember" value="yes">
<label for="chkremember"> Remember Me </label>
</div>
<div class="c2">
<button> Login </button>
</div>
</form>
</div>
</body>
</html>
Animations
==>Animations are "group of transitions",which will be performed one after another
==>Transition contains two points only(starting + ending)
==>Animation contains multiple points of milestones
Syntax :
selector
{
animation : animationname seconds;
}
@keyframes animationname
{
0%{ property:value;property:value;....},
25%{ property:value;property:value;....},
50%{ property:value;property:value;....},
75%{ property:value;property:value;....},
100%{ property:value;property:value;....}
}
Example : font-size
<html>
<head>
<title> Animations </title>
<style>
#div1
{
background-color: #2eda59;
font-size: 35px;
width:300px;
height:230px;
margin:60px;
}
#div1:hover
{
cursor:pointer;
animation:myanimation 5s; //fastness of moving the image
}
@keyframes myanimation
{
0%{transform:translate(0px,0px);}
25%{transform:translate(50px,0px);}
50%{transform:translate(50px,100px);}
75%{transform:translate(0px,100px);}
100%{transform:translate(0px,0px);}
}
</style>
</head>
<body>
<div id="div1">
<img src="[Link]" width="300px">
INDIA
</div>
</body>
</html>
<div id="nav">
Navigation
</div>
<div id="container">
<div id="leftCol">
LeftCol
</div>
<div id="pagecontent">
Page Content
</div>
</div>
<div id="Footer">
Footer
</div>
</div>
</body>
</html>
[Link]
<!--[Link]-->
<html>
<head>
<title> Home </title>
<link href="[Link]" rel="stylesheet">
</head>
<body>
<div id="outercontainer">
<div id="header">
Header
</div>
<div id="nav">
<a href ="[Link]"> Home</a>
<a href ="[Link]"> About </a>
<a href ="[Link]">Contact </a>
</div>
<div id="container">
<div id="leftCol">
LeftCol
</div>
<div id="pagecontent">
Home Page Content
</div>
</div>
<div id="footer">
Footer
</div>
</body>
</html>
[Link]
==========
<html>
<head>
<title> About </title>
<link href="[Link]" rel="stylesheet">
</head>
<body>
<div id="outercontainer">
<div id="header">
Header
</div>
<div id="nav">
<a href ="[Link]"> Home</a>
<a href ="[Link]"> About </a>
<a href ="[Link]">Contact </a>
</div>
<div id="container">
<div id="leftCol">
LeftCol
</div>
<div id="pagecontent">
About Page Content
</div>
</div>
<div id="footer">
Footer
</div>
</body>
</html>
=============================
[Link]
---------------
<html>
<head>
<title> Contact </title>
<link href="[Link]" rel="stylesheet">
</head>
<body>
<div id="outercontainer">
<div id="header">
Header
</div>
<div id="nav">
<a href ="[Link]"> Home</a>
<a href ="[Link]"> About </a>
<a href ="[Link]">Contact </a>
</div>
<div id="container">
<div id="leftCol">
LeftCol
</div>
<div id="Page content">
Contact Page Content
</div>
</div>
<div id="footer">
Footer
</div>
</body>
</html>
[Link]
=============
<style>
<body>
{
font-size:20px;
}
*
{
margin:0px;
padding:0px;
}
#outercontainer
{
background-color:#ffccff;
width:100%
margin:auto;
}
#header
{
background-color:#00ff99;
height:200px;
width:100%;
}
#nav
{
background-color:#ccccff;
height:80px;
width:100%;
}
#container
{
height:500px;
width:100%;
}
#leftcol
{
height:500px;
background-color:#66ccff;
width:20%;
float:left;
}
#pagecontent
{
height:500px;
background-color:#ccffcc;
width:80%;
float:left;
}
#footer
{
height:50px;
background-color:#ff0099;
width:100%;
clear:left;
}
</style>