Documente Academic
Documente Profesional
Documente Cultură
Session 1
Calling CSS
Calling css file in your html page
External style sheet
Below code is external file code (file name is style.css), this file is create external in your
project folder and save with .css extensions
Style.css file name write cod in your css file (create one file and save .css extensions )
Start css code
body {
background-color: lightblue;
}
h1 {
color: blue;
}
p{
color: red;
}
End css code
Write html program in your html body section
<html>
<head>
<title>external css calling</title>
<link rel="stylesheet" type="text/css" href="Style.css">
</head.
<body>
<h1>This is a Heading</h1>
<p>We assure comprehensive services to match the global standard of excellence</p>
<p>This is another paragraph.</p>
</body>
1
CSS & CSS 3
</html>
Output
2
CSS & CSS 3
<!DOCTYPE html>
<html>
<head>
<title>Internal Style Sheet</title>
Begin internal style sheet
<style type="text/css">
body {background-color: #0000FF;}
</style>
End internal style
</head>
Below internal style sheet
<body >
<h1>This is internal style sheet</h1>
</body>
Output
3
CSS & CSS 3
4
CSS & CSS 3
Session 2
Colors
Below style is inline style
Background-Color
Write background color your own color like below in your body part
<!DOCTYPE html>
<html>
<head>
<title>Background Colors</title>
</head>
<body>
Below we are writing inline style sheet
<h2 style="background-color:red">
Welcome to Tech Mahindra with Red Color
</h2>
<h2 style="background-color:blue;color:white">
Welcome to Tech Mahindra with Blue and White Color
</h2>
</body>
</html>
Output
5
CSS & CSS 3
6
CSS & CSS 3
7
CSS & CSS 3
Session 3
8
CSS & CSS 3
Output
Background Image
How to calling background image
<!DOCTYPE html>
<html>
<head>
<title>Background Image calling</title>
<style>
body {
background-image: url(pattern.jpg);
}
</style>
</head>
<body>
<h1>Welcome to Tech Mahindra</h1>
<p>This page has an image as background</p>
</body>
</html>
9
CSS & CSS 3
Output:
10
CSS & CSS 3
</body>
</html>
Output:
11
CSS & CSS 3
</body>
</html>
Output:
12
CSS & CSS 3
</head>
<body>
<h1>Welcome to Tech Mahindra</h1>
<p>This page has an image as background</p>
</body>
</html>
Output:
13
CSS & CSS 3
</style>
</head>
<body>
<h1>Welcome to Tech Mahindra</h1>
<p>Now the background image is only shown once, and positioned away from the text.</p>
<p>In this example we have also added a margin on the right side, so the background image
will never disturb the text.</p>
</body>
</html>
Output:
14
CSS & CSS 3
</style>
</head>
<body>
<h1>Hello World!</h1>
<p>Welcome to Tech Mahindra. The background-image is fixed. Try to scroll down the
page.</p>
<p>Welcome to Tech Mahindra. </p>
<p>Welcome to Tech Mahindra. </p>
<p>Welcome to Tech Mahindra. </p>
<p>Welcome to Tech Mahindra. </p>
<p>Welcome to Tech Mahindra. </p>
<p>Welcome to Tech Mahindra. </p>
<p>Welcome to Tech Mahindra. </p>
<p>Welcome to Tech Mahindra. The background-image is fixed. Try to scroll down the
page.</p>
<p>Welcome to Tech Mahindra. </p>
<p>Welcome to Tech Mahindra. </p>
<p>Welcome to Tech Mahindra. </p>
<p>Welcome to Tech Mahindra. </p>
<p>Welcome to Tech Mahindra. </p>
<p>Welcome to Tech Mahindra. </p>
<p>Welcome to Tech Mahindra. </p>
<p>Welcome to Tech Mahindra. </p>
<p>Welcome to Tech Mahindra. </p>
<p>Welcome to Tech Mahindra. </p>
<p>If you do not see any scrollbars, try to resize the browser window.</p>
</body>
</html>
Note: we are added ex
15
CSS & CSS 3
Output:
16
CSS & CSS 3
Session 4
Borders (@All Types)
<!DOCTYPE html>
<html>
<title>Borders</title>
<head>
Start internal style
<style>
body {
background-color: lightblue;
}
h1 {
color: blue; border-style: dashed;
}
p{
color: red;
}
p.dotted {border-style: dotted;}
p.mix {border-style: dotted dashed solid double;}
</style>
End internal style
</head>
<body>
<h1>This is a Heading</h1>
<p class="dotted">We assure comprehensive services to match the global standard of
excellence</p>
<p class="mix">This is another paragraph.</p>
</body>
</html>
17
CSS & CSS 3
Output
Rounded Borders
<!DOCTYPE html>
<html>
<head>
Start internal style
<style>
body {
background-color: lightblue;
}
h1 {
color: blue; border-style: dashed;
}
p{
color: red;
}
p.dotted {border-style: dotted;}
p.mix {border-style: dotted dashed solid double;}
p.normal {
18
CSS & CSS 3
19
CSS & CSS 3
Buttons
<!DOCTYPE html>
<html>
<head>
Start internal style
<style>
.button {
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
.button1 {border-radius: 2px; background:#06C}
20
CSS & CSS 3
21
CSS & CSS 3
Session 5
Font Icons
<!DOCTYPE html>
<html>
<head>
Calling external fonts url in your html header part
Go to https://cdnjs.com/ and enter in search bar “font-awesome”
Copy and paste url in your html header part
22
CSS & CSS 3
23
CSS & CSS 3
Section 6
Animation
Step 1: Marquee
Program:
<!DOCTYPE html>
<html>
<head>
<title>Marquee</title>
</head>
<body>
<MARQUEE WIDTH=400 HEIGHT=50>Welcome</MARQUEE></br>
<MARQUEE WIDTH="25%" BGCOLOR=YELLOW HEIGHT=50
DIRECTION=right>welcome!</MARQUEE>
<MARQUEE WIDTH=400 HEIGHT=50 DIRECTION=LeFT><p><img src="tree.jpg" alt="Forest"
width="108" height="104"></p></MARQUEE>
</body>
</html>
Output:
Step 2: Animation
Program:
<!DOCTYPE html>
<html>
<head>
<style>
24
CSS & CSS 3
25
CSS & CSS 3
<p>Make an element go from 0px to 200px from the left. The animation should take 5
seconds and it should go on forever (infinitely).</p>
<div></div>
<p><strong>Note:</strong> The animation property is not supported in Internet Explorer 9
and earlier versions.</p>
</body>
</html>
Output:
26
CSS & CSS 3
<head>
<style>
div {
width: 100px;height: 100px;
background: red;position: relative;
-webkit-animation: myfirst 5s infinite; /* Safari 4.0 - 8.0 */
-webkit-animation-direction: alternate; /* Safari 4.0 - 8.0 */
animation: myfirst 5s infinite;
animation-direction: alternate;
}
/* Safari 4.0 - 8.0 */
@-webkit-keyframes myfirst {
0% {background: red; left: 0px; top: 0px;}
25% {background: yellow; left: 200px; top: 0px;}
50% {background: blue; left: 200px; top: 200px;}
75% {background: green; left: 0px; top: 200px;}
100% {background: red; left: 0px; top: 0px;}
}
@keyframes myfirst {
0% {background: red; left: 0px; top: 0px;}
25% {background: yellow; left: 200px; top: 0px;}
50% {background: blue; left: 200px; top: 200px;}
75% {background: green; left: 0px; top: 200px;}
100% {background: red; left: 0px; top: 0px;}
}
</style>
</head>
<body>
27
CSS & CSS 3
28
CSS & CSS 3
29
CSS & CSS 3
</body>
</html>
30
CSS & CSS 3
Output:
31
CSS & CSS 3
32
CSS & CSS 3
Output:
33
CSS & CSS 3
Section 7
Opacity
Opacity 30%
<!DOCTYPE html>
<html>
<head>
Start internal style
<style>
img {
opacity: 0.3;
filter: alpha(opacity=30);
}
</style>
End internal style
</head>
<body>
<h1>Image Transparency</h1>
<p>The opacity property specifies the transparency of an element. The lower the value, the
more transparent:</p>
<p><img src="tree.jpg" alt="Forest" width="233" height="302"></p>
</body>
</html>
Output
34
CSS & CSS 3
Opacity 60%
<!DOCTYPE html>
<html>
<head>
Start internal style
<style>
img {
opacity: 0.6;
filter: alpha(opacity=60);
}
</style>
End internal style
</head>
<body>
<h1>Image Transparency</h1>
35
CSS & CSS 3
<p>The opacity property specifies the transparency of an element. The lower the value, the
more transparent:</p>
<p><img src="tree.jpg" alt="Forest" width="233" height="302"></p>
</body>
</html>
Output
36