SlideShare a Scribd company logo
CSS(Cascading Style Sheets )
CSS stands for Cascading Style
Sheets
Styles define how to display HTML
elements
CSS has various levels and profiles. Each level of CSS
builds upon the last, typically adding new features and
typically denoted as CSS1, CSS2, and CSS3.
The first CSS specification to become an official W3C
Recommendation is CSS level 1, published in December
1996
CSS level 2 was developed by the W3C and published as
a Recommendation in May 1998. A superset of CSS1,
CSS2 includes a number of new capabilities like absolute,
relative, and fixed positioning of elements and z-index, the
concept of media types etc.
CSS 3
CSS level 3 is currently under development. The W3C
maintains a CSS3 progress report.
 CSS Saves a Lot of Work!
 CSS defines HOW HTML elements are to
be displayed.
 Styles are normally saved in external .css
files. External style sheets enable you to
change the appearance and layout of all
the pages in a Web site, just by editing
one single file!
Understanding Style Rules
Understanding Style Rules
 A Style Rule
Style Rule is composed of two parts: a
selector and a declaration.
TH {color: red;}.
 The Selector
Selector indicates the element to which the
rule is applied.
 The Declaration
Declaration determines the property values
of a selector.
Selector
Declaration
Understanding Style Rules
Understanding Style Rules
 The Property
Property specifies a characteristic, such as
color, font-family, position, and is followed by a
colon (:).
 The Value
Value expresses specification of a property,
such as red for color, arial for font family, 12 pt
for font-size, and is followed by a semicolon (;).
P {color: red;}
Property Value
 CSS declarations always ends with a semicolon, and declaration groups are
surrounded by curly brackets:
 p {color:red;text-align:center;}To make the CSS more readable, you can put one
declaration on each line, like this:
 Example
 p
{
color:red;
text-align:center;
}
CSS Comments
 A CSS comment begins with "/*", and ends with "*/", like this:
 /*This is a comment*/
p
{
text-align:center;
/*This is another comment*/
color:black;
font-family:arial;
}
 The id and class Selectors
 In addition to setting a style for a HTML element, CSS allows you to
specify your own selectors called "id" and "class".
 The id Selector
 The id selector is used to specify a style for a single, unique element.
 The id selector uses the id attribute of the HTML element, and is defined with a
"#".
 The style rule below will be applied to the element with id="para1":
 Example
 #para1
{
text-align:center;
color:red;
}
The class Selector
 The class selector is used to specify a style for a group of elements. Unlike
the id selector, the class selector is most often used on several elements.
 This allows you to set a particular style for any HTML elements with the
same class.
 The class selector uses the HTML class attribute, and is defined with a "."
 In the example below, all HTML elements with class="center" will be
center-aligned:
 Example
 .center
 {
 text-align:center;
 }
 In the example below, all p elements with class="center" will be center-
aligned:
 Example
 p.center {text-align:center;}
Three Ways to Insert CSS
External style sheet
Internal style sheet
Inline style
External Style Sheet
An external style sheet is ideal when the style is applied to many pages. With an external
style sheet, you can change the look of an entire Web site by changing one file. Each page
must link to the style sheet using the <link> tag. The <link> tag goes inside the head
section:
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css" />
</head>
An external style sheet can be written in any text editor. The file should not contain any
html tags. Your style sheet should be saved with a .css extension. An example of a style
sheet file is shown below:
hr {color:red;}
p {margin-left:20px;}
body {background-image:url("images/back40.gif");}
Internal Style Sheet
An internal style sheet should be used when a single
document has a unique style.
<head>
<style type="text/css">
hr {color:red;}
p {margin-left:20px;}
body {background-image:url("images/back40.gif");}
</style>
</head>
Inline Styles
<p style="color:red;margin-left:20px">This is a paragraph.</p>
Multiple Style Sheets
If some properties have been set for the same selector in different style sheets, the values will
be inherited from the more specific style sheet.
For example, an external style sheet has these properties for the h3 selector:
h3
{
color:red;
text-align:left;
font-size:8pt;
}
And an internal style sheet has these properties for the h3 selector:
h3
{
text-align:right;
font-size:20pt;
}
If the page with the internal style sheet also links to the external style sheet the properties for
h3 will be:
color:red;
text-align:right;
font-size:20pt;
The color is inherited from the external style sheet and the text-alignment and the font-size is
replaced by the internal style sheet.
 More examples
 body {background-color:#b0c4de;}
h1 {background-color:#6495ed;}
p {background-color:#e0ffff;}
div {background-color:#b0c4de;}
 body {background-image:url('paper.gif');}
 body
{
background-image:url('gradient2.png');
background-repeat:repeat-x;
}

body
{
background-image:url('img_tree.png');
background-repeat:no-repeat;
}

 body
{
background-image:url('img_tree.png');
background-repeat:no-repeat;
background-position:top right;
}
in short it can be written as:
 body {background:#ffffff url('img_tree.png') no-repeat
top right;}
body {color:blue;}
h1 {color:#00ff00;}
h2 {color:rgb(255,0,0);}
h1 {text-align:center;}
p.date {text-align:right;}
p.main {text-align:justify;}
A
{
text-decoration:none;
}
p.uppercase {text-transform:uppercase;}
p.lowercase {text-transform:lowercase;}
p.capitalize {text-transform:capitalize;}
p {
text-indent:50px;}
 Font Family
 The font family of a text is set with the
font-family property.
 The font-family property should hold
several font names as a "fallback" system.
If the browser does not support the first
font, it tries the next font.
 p{font-family:"Times New Roman", Times,
serif;}
 p.normal {font-style:normal;}
p.italic {font-style:italic;}
p.oblique {font-style:oblique;}
 h1 {font-size:40px;}
h2 {font-size:30px;}
p {font-size:14px;}
 Set Font Size With Em
 To avoid the resizing problem with Internet Explorer,
many developers use em instead of pixels.
 The em size unit is recommended by the W3C.
 1em is equal to the current font size. The default text
size in browsers is 16px. So, the default size of 1em
is 16px.
 The size can be calculated from pixels to em using
this formula: pixels/16=em
 Example
 h1 {font-size:2.5em;} /* 40px/16=2.5em */
h2 {font-size:1.875em;} /* 30px/16=1.875em */
p {font-size:0.875em;} /* 14px/16=0.875em */
 Styling Links
 Links can be style with any CSS property (e.g. color, font-family, background-color).
 Special for links are that they can be styled differently depending on what state they
are in.
 The four links states are:
 a:link - a normal, unvisited link
 a:visited - a link the user has visited
 a:hover - a link when the user mouses over it
 a:active - a link the moment it is clicked
 Example
 a:link {color:#FF0000;} /* unvisited link */
a:visited {color:#00FF00;} /* visited link */
a:hover {color:#FF00FF;} /* mouse over link */
a:active {color:#0000FF;} /* selected link */
 a:link {text-decoration:none;}
a:visited {text-decoration:none;}
a:hover {text-decoration:underline;}
a:active {text-decoration:underline;}
 a:link {background-color:#B2FF99;}
a:visited {background-color:#FFFF85;}
a:hover {background-color:#FF704D;}
a:active {background-color:#FF704D;}
 ul.a {list-style-type: circle;}
ul.b {list-style-type: square;}
ol.c {list-style-type: upper-roman;}
ol.d {list-style-type: lower-alpha;}
 ul
{
list-style-image: url('sqpurple.jpg');
}
 table, th, td
{
border: 1px solid black;
}

table,th, td
{
border: 1px solid black;
}
td
{
height:50px;
vertical-align:bottom;
}
td
{
padding:15px;
}
table, td, th
{
border:1px solid green;
}
th
{
background-color:green;
color:white;
}
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style type="text/css">
div.ex
{
width:220px;
padding:10px;
border:5px solid gray;
margin:0px;
}
</style>
</head>
 <style>
 .contentBox
 { display:block; border-width: 1px; border-
style: solid; border-color: 000; padding:5px;
margin-top:5px; width:200px; height:50px;
overflow:scroll
 }
 </style>
 <div class="contentBox"> Why do I call
them "CSS Scrollbars"?
 </div>
 p
{
border-top-style:dotted;
border-right-style:solid;
border-bottom-style:dotted;
border-left-style:solid;
}
 <html>
 <head>
 <style type="text/css">
 p
 {
 background-color:yellow;
 }
 p.padding
 {
 padding-top:25px;
 padding-bottom:25px;
 padding-right:50px;
 padding-left:50px;
 }
 </style>
 </head>
 <body>
 <p>This is a paragraph with no specified padding.</p>
 <p class="padding">This is a paragraph with specified paddings.</p>
 </body>
 </html>
 <html>
 <head>
 <style type="text/css">
 h1,h2,p
 {
 color:green;
 }
 </style>
 </head>
 <body>
 <h1>Hello World!</h1>
 <h2>Smaller heading!</h2>
 <p>This is a paragraph.</p>
 </body>
 </html>
 <html>
 <head>
 <style type="text/css">
 p
 {
 color:blue;
 text-align:center;
 }
 .marked p
 {
 color:white;
 }
 </style>
 </head>
 <body>
 <p>This is a blue, center-aligned paragraph.</p>
 <div class="marked">
 <p>This p element should not be blue.</p>
 </div>
 </body>
 </html>
<html>
<head>
<style type="text/css">
h1.hidden {visibility:hidden;}
</style>
</head>
<body>
<h1>This is a visible heading</h1>
<h1 class="hidden">This is a hidden heading</h1>
<p>Notice that the hidden heading still takes up space.</p>
</body>
</html>
O/P
This is a visible heading
Notice that the hidden heading still takes up space.
 <html>
 <head>
 <style type="text/css">
 img
 {
 position:absolute;
 left:0px;
 top:0px;
 z-index:-1;
 }
 </style>
 </head>
 <body>
 <h1>This is a heading</h1>
 <img src=“mitrc.jpg" width="100"
height="40" />
 <p style=“color:red”>Because the
image has a z-index of -1, it will be
placed behind the text.</p>
 </body>
 </html>
This is a headin
Because the image has a z-index of -1, it will be placed
behind the text
 Advantages of CSS
 CSS saves time
When most of us first learn HTML, we get taught to set the font face, size,
colour, style etc every time it occurs on a page. This means we find
ourselves typing (or copying & pasting) the same thing over and over again.
With CSS, you only have to specify these details once for any element. CSS
will automatically apply the specified styles whenever that element occurs.
 Pages load faster
Less code means faster download times.
 Easy maintenance
To change the style of an element, you only have to make an edit in one
place.
 Superior styles to HTML
CSS has a much wider array of attributes than HTML.
 Disadvantages of CSS
 Browser compatibility
Browsers have varying levels of compliance with Style Sheets. This means
that some Style Sheet features are supported and some aren't. To confuse
things more, some browser manufacturers decide to come up with their own
proprietary tags.

More Related Content

Similar to cdocumentsandsettingsstudentdesktopnewfolderhtmlcss-100220030010-phpapp01.pdf (20)

css1.ppt
css1.pptcss1.ppt
css1.ppt
BalasundaramSr
 
waxaada canshuurahaiyosiyaaddaguudeexamarwaaardaydaDAALBADAN.ppt
waxaada canshuurahaiyosiyaaddaguudeexamarwaaardaydaDAALBADAN.pptwaxaada canshuurahaiyosiyaaddaguudeexamarwaaardaydaDAALBADAN.ppt
waxaada canshuurahaiyosiyaaddaguudeexamarwaaardaydaDAALBADAN.ppt
Ismaciil2
 
TUTORIAL DE CSS 2.0
TUTORIAL DE CSS 2.0TUTORIAL DE CSS 2.0
TUTORIAL DE CSS 2.0
Vladimir Valencia
 
html-css
html-csshtml-css
html-css
Dhirendra Chauhan
 
v5-introduction to html-css-210321161444.pptx
v5-introduction to html-css-210321161444.pptxv5-introduction to html-css-210321161444.pptx
v5-introduction to html-css-210321161444.pptx
hannahroseline2
 
v5-introduction to html-css-210321161444.pptx
v5-introduction to html-css-210321161444.pptxv5-introduction to html-css-210321161444.pptx
v5-introduction to html-css-210321161444.pptx
hannahroseline2
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
tutorialsruby
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
tutorialsruby
 
Chapter 4a cascade style sheet css
Chapter 4a cascade style sheet cssChapter 4a cascade style sheet css
Chapter 4a cascade style sheet css
Tesfaye Yenealem
 
Css1
Css1Css1
Css1
Pulkit Tanwar
 
Css tutorial
Css tutorialCss tutorial
Css tutorial
vedaste
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
Senthil Kumar
 
5th Lecture- WEB ENGINEERING basics.pptx
5th Lecture- WEB ENGINEERING basics.pptx5th Lecture- WEB ENGINEERING basics.pptx
5th Lecture- WEB ENGINEERING basics.pptx
Aasma13
 
CSS_Day_ONE (W3schools)
CSS_Day_ONE (W3schools)CSS_Day_ONE (W3schools)
CSS_Day_ONE (W3schools)
Rafi Haidari
 
4_css_intro.pptx. this ppt is based on css which is the required of web deve...
4_css_intro.pptx.  this ppt is based on css which is the required of web deve...4_css_intro.pptx.  this ppt is based on css which is the required of web deve...
4_css_intro.pptx. this ppt is based on css which is the required of web deve...
sindwanigripsi
 
CSS
CSSCSS
CSS
Deepa Lakshmi
 
CSS____4563276__HTML___________0989.pptx
CSS____4563276__HTML___________0989.pptxCSS____4563276__HTML___________0989.pptx
CSS____4563276__HTML___________0989.pptx
Ajanya5
 
Css(handbook)
Css(handbook)Css(handbook)
Css(handbook)
MD. Anamul Haque
 
IP - Lecture 6, 7 Chapter-3 (3).ppt
IP - Lecture 6, 7 Chapter-3 (3).pptIP - Lecture 6, 7 Chapter-3 (3).ppt
IP - Lecture 6, 7 Chapter-3 (3).ppt
kassahungebrie
 
CSS
CSSCSS
CSS
DivyaKS12
 
waxaada canshuurahaiyosiyaaddaguudeexamarwaaardaydaDAALBADAN.ppt
waxaada canshuurahaiyosiyaaddaguudeexamarwaaardaydaDAALBADAN.pptwaxaada canshuurahaiyosiyaaddaguudeexamarwaaardaydaDAALBADAN.ppt
waxaada canshuurahaiyosiyaaddaguudeexamarwaaardaydaDAALBADAN.ppt
Ismaciil2
 
v5-introduction to html-css-210321161444.pptx
v5-introduction to html-css-210321161444.pptxv5-introduction to html-css-210321161444.pptx
v5-introduction to html-css-210321161444.pptx
hannahroseline2
 
v5-introduction to html-css-210321161444.pptx
v5-introduction to html-css-210321161444.pptxv5-introduction to html-css-210321161444.pptx
v5-introduction to html-css-210321161444.pptx
hannahroseline2
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
tutorialsruby
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
tutorialsruby
 
Chapter 4a cascade style sheet css
Chapter 4a cascade style sheet cssChapter 4a cascade style sheet css
Chapter 4a cascade style sheet css
Tesfaye Yenealem
 
Css tutorial
Css tutorialCss tutorial
Css tutorial
vedaste
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
Senthil Kumar
 
5th Lecture- WEB ENGINEERING basics.pptx
5th Lecture- WEB ENGINEERING basics.pptx5th Lecture- WEB ENGINEERING basics.pptx
5th Lecture- WEB ENGINEERING basics.pptx
Aasma13
 
CSS_Day_ONE (W3schools)
CSS_Day_ONE (W3schools)CSS_Day_ONE (W3schools)
CSS_Day_ONE (W3schools)
Rafi Haidari
 
4_css_intro.pptx. this ppt is based on css which is the required of web deve...
4_css_intro.pptx.  this ppt is based on css which is the required of web deve...4_css_intro.pptx.  this ppt is based on css which is the required of web deve...
4_css_intro.pptx. this ppt is based on css which is the required of web deve...
sindwanigripsi
 
CSS____4563276__HTML___________0989.pptx
CSS____4563276__HTML___________0989.pptxCSS____4563276__HTML___________0989.pptx
CSS____4563276__HTML___________0989.pptx
Ajanya5
 
IP - Lecture 6, 7 Chapter-3 (3).ppt
IP - Lecture 6, 7 Chapter-3 (3).pptIP - Lecture 6, 7 Chapter-3 (3).ppt
IP - Lecture 6, 7 Chapter-3 (3).ppt
kassahungebrie
 

Recently uploaded (20)

Multicultural approach in education - B.Ed
Multicultural approach in education - B.EdMulticultural approach in education - B.Ed
Multicultural approach in education - B.Ed
prathimagowda443
 
A Brief Introduction About Jack Lutkus
A Brief Introduction About  Jack  LutkusA Brief Introduction About  Jack  Lutkus
A Brief Introduction About Jack Lutkus
Jack Lutkus
 
"Orthoptera: Grasshoppers, Crickets, and Katydids pptx
"Orthoptera: Grasshoppers, Crickets, and Katydids pptx"Orthoptera: Grasshoppers, Crickets, and Katydids pptx
"Orthoptera: Grasshoppers, Crickets, and Katydids pptx
Arshad Shaikh
 
Types of Actions in Odoo 18 - Odoo Slides
Types of Actions in Odoo 18 - Odoo SlidesTypes of Actions in Odoo 18 - Odoo Slides
Types of Actions in Odoo 18 - Odoo Slides
Celine George
 
Network Security Essentials 6th Edition.pdf
Network Security Essentials 6th Edition.pdfNetwork Security Essentials 6th Edition.pdf
Network Security Essentials 6th Edition.pdf
datmieu2004
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-25-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-25-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-25-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-25-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
Unit 4 Legal Issues in Reverse Engineering.pdf
Unit 4 Legal Issues in Reverse Engineering.pdfUnit 4 Legal Issues in Reverse Engineering.pdf
Unit 4 Legal Issues in Reverse Engineering.pdf
ChatanBawankar
 
QUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptx
QUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptxQUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptx
QUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptx
Sourav Kr Podder
 
How to create and manage blogs in odoo 18
How to create and manage blogs in odoo 18How to create and manage blogs in odoo 18
How to create and manage blogs in odoo 18
Celine George
 
Education Funding Equity in North Carolina: Looking Beyond Income
Education Funding Equity in North Carolina: Looking Beyond IncomeEducation Funding Equity in North Carolina: Looking Beyond Income
Education Funding Equity in North Carolina: Looking Beyond Income
EducationNC
 
ISO 27001 Lead Auditor Exam Practice Questions and Answers-.pdf
ISO 27001 Lead Auditor Exam Practice Questions and Answers-.pdfISO 27001 Lead Auditor Exam Practice Questions and Answers-.pdf
ISO 27001 Lead Auditor Exam Practice Questions and Answers-.pdf
infosec train
 
Unit 4 Reverse Engineering Tools Functionalities & Use-Cases.pdf
Unit 4  Reverse Engineering Tools  Functionalities & Use-Cases.pdfUnit 4  Reverse Engineering Tools  Functionalities & Use-Cases.pdf
Unit 4 Reverse Engineering Tools Functionalities & Use-Cases.pdf
ChatanBawankar
 
QUIZ-O-FORCE 3.0 FINAL SET BY SOURAV .pptx
QUIZ-O-FORCE 3.0 FINAL SET BY SOURAV .pptxQUIZ-O-FORCE 3.0 FINAL SET BY SOURAV .pptx
QUIZ-O-FORCE 3.0 FINAL SET BY SOURAV .pptx
Sourav Kr Podder
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-30-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-30-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
General Knowledge Quiz / Pub Quiz lvl 1.pptx
General Knowledge Quiz / Pub Quiz lvl 1.pptxGeneral Knowledge Quiz / Pub Quiz lvl 1.pptx
General Knowledge Quiz / Pub Quiz lvl 1.pptx
fxbktvnp8b
 
How to Use Owl Slots in Odoo 17 - Odoo Slides
How to Use Owl Slots in Odoo 17 - Odoo SlidesHow to Use Owl Slots in Odoo 17 - Odoo Slides
How to Use Owl Slots in Odoo 17 - Odoo Slides
Celine George
 
Policies, procedures, subject selection and QTAC.pptx
Policies, procedures, subject selection and QTAC.pptxPolicies, procedures, subject selection and QTAC.pptx
Policies, procedures, subject selection and QTAC.pptx
mansk2
 
Research Handbook On Environment And Investment Law Kate Miles
Research Handbook On Environment And Investment Law Kate MilesResearch Handbook On Environment And Investment Law Kate Miles
Research Handbook On Environment And Investment Law Kate Miles
mucomousamir
 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
siemaillard
 
Flower Identification Class-10 by Kushal Lamichhane.pdf
Flower Identification Class-10 by Kushal Lamichhane.pdfFlower Identification Class-10 by Kushal Lamichhane.pdf
Flower Identification Class-10 by Kushal Lamichhane.pdf
kushallamichhame
 
Multicultural approach in education - B.Ed
Multicultural approach in education - B.EdMulticultural approach in education - B.Ed
Multicultural approach in education - B.Ed
prathimagowda443
 
A Brief Introduction About Jack Lutkus
A Brief Introduction About  Jack  LutkusA Brief Introduction About  Jack  Lutkus
A Brief Introduction About Jack Lutkus
Jack Lutkus
 
"Orthoptera: Grasshoppers, Crickets, and Katydids pptx
"Orthoptera: Grasshoppers, Crickets, and Katydids pptx"Orthoptera: Grasshoppers, Crickets, and Katydids pptx
"Orthoptera: Grasshoppers, Crickets, and Katydids pptx
Arshad Shaikh
 
Types of Actions in Odoo 18 - Odoo Slides
Types of Actions in Odoo 18 - Odoo SlidesTypes of Actions in Odoo 18 - Odoo Slides
Types of Actions in Odoo 18 - Odoo Slides
Celine George
 
Network Security Essentials 6th Edition.pdf
Network Security Essentials 6th Edition.pdfNetwork Security Essentials 6th Edition.pdf
Network Security Essentials 6th Edition.pdf
datmieu2004
 
Unit 4 Legal Issues in Reverse Engineering.pdf
Unit 4 Legal Issues in Reverse Engineering.pdfUnit 4 Legal Issues in Reverse Engineering.pdf
Unit 4 Legal Issues in Reverse Engineering.pdf
ChatanBawankar
 
QUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptx
QUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptxQUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptx
QUIZ-O-FORCE FINAL SET BY SUDIPTA & SUBHAM.pptx
Sourav Kr Podder
 
How to create and manage blogs in odoo 18
How to create and manage blogs in odoo 18How to create and manage blogs in odoo 18
How to create and manage blogs in odoo 18
Celine George
 
Education Funding Equity in North Carolina: Looking Beyond Income
Education Funding Equity in North Carolina: Looking Beyond IncomeEducation Funding Equity in North Carolina: Looking Beyond Income
Education Funding Equity in North Carolina: Looking Beyond Income
EducationNC
 
ISO 27001 Lead Auditor Exam Practice Questions and Answers-.pdf
ISO 27001 Lead Auditor Exam Practice Questions and Answers-.pdfISO 27001 Lead Auditor Exam Practice Questions and Answers-.pdf
ISO 27001 Lead Auditor Exam Practice Questions and Answers-.pdf
infosec train
 
Unit 4 Reverse Engineering Tools Functionalities & Use-Cases.pdf
Unit 4  Reverse Engineering Tools  Functionalities & Use-Cases.pdfUnit 4  Reverse Engineering Tools  Functionalities & Use-Cases.pdf
Unit 4 Reverse Engineering Tools Functionalities & Use-Cases.pdf
ChatanBawankar
 
QUIZ-O-FORCE 3.0 FINAL SET BY SOURAV .pptx
QUIZ-O-FORCE 3.0 FINAL SET BY SOURAV .pptxQUIZ-O-FORCE 3.0 FINAL SET BY SOURAV .pptx
QUIZ-O-FORCE 3.0 FINAL SET BY SOURAV .pptx
Sourav Kr Podder
 
General Knowledge Quiz / Pub Quiz lvl 1.pptx
General Knowledge Quiz / Pub Quiz lvl 1.pptxGeneral Knowledge Quiz / Pub Quiz lvl 1.pptx
General Knowledge Quiz / Pub Quiz lvl 1.pptx
fxbktvnp8b
 
How to Use Owl Slots in Odoo 17 - Odoo Slides
How to Use Owl Slots in Odoo 17 - Odoo SlidesHow to Use Owl Slots in Odoo 17 - Odoo Slides
How to Use Owl Slots in Odoo 17 - Odoo Slides
Celine George
 
Policies, procedures, subject selection and QTAC.pptx
Policies, procedures, subject selection and QTAC.pptxPolicies, procedures, subject selection and QTAC.pptx
Policies, procedures, subject selection and QTAC.pptx
mansk2
 
Research Handbook On Environment And Investment Law Kate Miles
Research Handbook On Environment And Investment Law Kate MilesResearch Handbook On Environment And Investment Law Kate Miles
Research Handbook On Environment And Investment Law Kate Miles
mucomousamir
 
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
siemaillard
 
Flower Identification Class-10 by Kushal Lamichhane.pdf
Flower Identification Class-10 by Kushal Lamichhane.pdfFlower Identification Class-10 by Kushal Lamichhane.pdf
Flower Identification Class-10 by Kushal Lamichhane.pdf
kushallamichhame
 

cdocumentsandsettingsstudentdesktopnewfolderhtmlcss-100220030010-phpapp01.pdf

  • 1. CSS(Cascading Style Sheets ) CSS stands for Cascading Style Sheets Styles define how to display HTML elements
  • 2. CSS has various levels and profiles. Each level of CSS builds upon the last, typically adding new features and typically denoted as CSS1, CSS2, and CSS3. The first CSS specification to become an official W3C Recommendation is CSS level 1, published in December 1996 CSS level 2 was developed by the W3C and published as a Recommendation in May 1998. A superset of CSS1, CSS2 includes a number of new capabilities like absolute, relative, and fixed positioning of elements and z-index, the concept of media types etc. CSS 3 CSS level 3 is currently under development. The W3C maintains a CSS3 progress report.
  • 3.  CSS Saves a Lot of Work!  CSS defines HOW HTML elements are to be displayed.  Styles are normally saved in external .css files. External style sheets enable you to change the appearance and layout of all the pages in a Web site, just by editing one single file!
  • 4. Understanding Style Rules Understanding Style Rules  A Style Rule Style Rule is composed of two parts: a selector and a declaration. TH {color: red;}.  The Selector Selector indicates the element to which the rule is applied.  The Declaration Declaration determines the property values of a selector. Selector Declaration
  • 5. Understanding Style Rules Understanding Style Rules  The Property Property specifies a characteristic, such as color, font-family, position, and is followed by a colon (:).  The Value Value expresses specification of a property, such as red for color, arial for font family, 12 pt for font-size, and is followed by a semicolon (;). P {color: red;} Property Value
  • 6.  CSS declarations always ends with a semicolon, and declaration groups are surrounded by curly brackets:  p {color:red;text-align:center;}To make the CSS more readable, you can put one declaration on each line, like this:  Example  p { color:red; text-align:center; } CSS Comments  A CSS comment begins with "/*", and ends with "*/", like this:  /*This is a comment*/ p { text-align:center; /*This is another comment*/ color:black; font-family:arial; }
  • 7.  The id and class Selectors  In addition to setting a style for a HTML element, CSS allows you to specify your own selectors called "id" and "class".  The id Selector  The id selector is used to specify a style for a single, unique element.  The id selector uses the id attribute of the HTML element, and is defined with a "#".  The style rule below will be applied to the element with id="para1":  Example  #para1 { text-align:center; color:red; }
  • 8. The class Selector  The class selector is used to specify a style for a group of elements. Unlike the id selector, the class selector is most often used on several elements.  This allows you to set a particular style for any HTML elements with the same class.  The class selector uses the HTML class attribute, and is defined with a "."  In the example below, all HTML elements with class="center" will be center-aligned:  Example  .center  {  text-align:center;  }  In the example below, all p elements with class="center" will be center- aligned:  Example  p.center {text-align:center;}
  • 9. Three Ways to Insert CSS External style sheet Internal style sheet Inline style External Style Sheet An external style sheet is ideal when the style is applied to many pages. With an external style sheet, you can change the look of an entire Web site by changing one file. Each page must link to the style sheet using the <link> tag. The <link> tag goes inside the head section: <head> <link rel="stylesheet" type="text/css" href="mystyle.css" /> </head> An external style sheet can be written in any text editor. The file should not contain any html tags. Your style sheet should be saved with a .css extension. An example of a style sheet file is shown below: hr {color:red;} p {margin-left:20px;} body {background-image:url("images/back40.gif");}
  • 10. Internal Style Sheet An internal style sheet should be used when a single document has a unique style. <head> <style type="text/css"> hr {color:red;} p {margin-left:20px;} body {background-image:url("images/back40.gif");} </style> </head>
  • 11. Inline Styles <p style="color:red;margin-left:20px">This is a paragraph.</p> Multiple Style Sheets If some properties have been set for the same selector in different style sheets, the values will be inherited from the more specific style sheet. For example, an external style sheet has these properties for the h3 selector: h3 { color:red; text-align:left; font-size:8pt; } And an internal style sheet has these properties for the h3 selector: h3 { text-align:right; font-size:20pt; } If the page with the internal style sheet also links to the external style sheet the properties for h3 will be: color:red; text-align:right; font-size:20pt; The color is inherited from the external style sheet and the text-alignment and the font-size is replaced by the internal style sheet.
  • 12.  More examples  body {background-color:#b0c4de;} h1 {background-color:#6495ed;} p {background-color:#e0ffff;} div {background-color:#b0c4de;}  body {background-image:url('paper.gif');}  body { background-image:url('gradient2.png'); background-repeat:repeat-x; }  body { background-image:url('img_tree.png'); background-repeat:no-repeat; } 
  • 13.  body { background-image:url('img_tree.png'); background-repeat:no-repeat; background-position:top right; } in short it can be written as:  body {background:#ffffff url('img_tree.png') no-repeat top right;}
  • 14. body {color:blue;} h1 {color:#00ff00;} h2 {color:rgb(255,0,0);} h1 {text-align:center;} p.date {text-align:right;} p.main {text-align:justify;} A { text-decoration:none; } p.uppercase {text-transform:uppercase;} p.lowercase {text-transform:lowercase;} p.capitalize {text-transform:capitalize;} p { text-indent:50px;}
  • 15.  Font Family  The font family of a text is set with the font-family property.  The font-family property should hold several font names as a "fallback" system. If the browser does not support the first font, it tries the next font.  p{font-family:"Times New Roman", Times, serif;}
  • 16.  p.normal {font-style:normal;} p.italic {font-style:italic;} p.oblique {font-style:oblique;}  h1 {font-size:40px;} h2 {font-size:30px;} p {font-size:14px;}
  • 17.  Set Font Size With Em  To avoid the resizing problem with Internet Explorer, many developers use em instead of pixels.  The em size unit is recommended by the W3C.  1em is equal to the current font size. The default text size in browsers is 16px. So, the default size of 1em is 16px.  The size can be calculated from pixels to em using this formula: pixels/16=em  Example  h1 {font-size:2.5em;} /* 40px/16=2.5em */ h2 {font-size:1.875em;} /* 30px/16=1.875em */ p {font-size:0.875em;} /* 14px/16=0.875em */
  • 18.  Styling Links  Links can be style with any CSS property (e.g. color, font-family, background-color).  Special for links are that they can be styled differently depending on what state they are in.  The four links states are:  a:link - a normal, unvisited link  a:visited - a link the user has visited  a:hover - a link when the user mouses over it  a:active - a link the moment it is clicked  Example  a:link {color:#FF0000;} /* unvisited link */ a:visited {color:#00FF00;} /* visited link */ a:hover {color:#FF00FF;} /* mouse over link */ a:active {color:#0000FF;} /* selected link */  a:link {text-decoration:none;} a:visited {text-decoration:none;} a:hover {text-decoration:underline;} a:active {text-decoration:underline;}  a:link {background-color:#B2FF99;} a:visited {background-color:#FFFF85;} a:hover {background-color:#FF704D;} a:active {background-color:#FF704D;}
  • 19.  ul.a {list-style-type: circle;} ul.b {list-style-type: square;} ol.c {list-style-type: upper-roman;} ol.d {list-style-type: lower-alpha;}  ul { list-style-image: url('sqpurple.jpg'); }
  • 20.  table, th, td { border: 1px solid black; }  table,th, td { border: 1px solid black; } td { height:50px; vertical-align:bottom; } td { padding:15px; } table, td, th { border:1px solid green; } th { background-color:green; color:white; }
  • 21.  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <style type="text/css"> div.ex { width:220px; padding:10px; border:5px solid gray; margin:0px; } </style> </head>
  • 22.  <style>  .contentBox  { display:block; border-width: 1px; border- style: solid; border-color: 000; padding:5px; margin-top:5px; width:200px; height:50px; overflow:scroll  }  </style>  <div class="contentBox"> Why do I call them "CSS Scrollbars"?  </div>
  • 24.  <html>  <head>  <style type="text/css">  p  {  background-color:yellow;  }  p.padding  {  padding-top:25px;  padding-bottom:25px;  padding-right:50px;  padding-left:50px;  }  </style>  </head>  <body>  <p>This is a paragraph with no specified padding.</p>  <p class="padding">This is a paragraph with specified paddings.</p>  </body>  </html>
  • 25.  <html>  <head>  <style type="text/css">  h1,h2,p  {  color:green;  }  </style>  </head>  <body>  <h1>Hello World!</h1>  <h2>Smaller heading!</h2>  <p>This is a paragraph.</p>  </body>  </html>
  • 26.  <html>  <head>  <style type="text/css">  p  {  color:blue;  text-align:center;  }  .marked p  {  color:white;  }  </style>  </head>  <body>  <p>This is a blue, center-aligned paragraph.</p>  <div class="marked">  <p>This p element should not be blue.</p>  </div>  </body>  </html>
  • 27. <html> <head> <style type="text/css"> h1.hidden {visibility:hidden;} </style> </head> <body> <h1>This is a visible heading</h1> <h1 class="hidden">This is a hidden heading</h1> <p>Notice that the hidden heading still takes up space.</p> </body> </html> O/P This is a visible heading Notice that the hidden heading still takes up space.
  • 28.  <html>  <head>  <style type="text/css">  img  {  position:absolute;  left:0px;  top:0px;  z-index:-1;  }  </style>  </head>  <body>  <h1>This is a heading</h1>  <img src=“mitrc.jpg" width="100" height="40" />  <p style=“color:red”>Because the image has a z-index of -1, it will be placed behind the text.</p>  </body>  </html> This is a headin Because the image has a z-index of -1, it will be placed behind the text
  • 29.  Advantages of CSS  CSS saves time When most of us first learn HTML, we get taught to set the font face, size, colour, style etc every time it occurs on a page. This means we find ourselves typing (or copying & pasting) the same thing over and over again. With CSS, you only have to specify these details once for any element. CSS will automatically apply the specified styles whenever that element occurs.  Pages load faster Less code means faster download times.  Easy maintenance To change the style of an element, you only have to make an edit in one place.  Superior styles to HTML CSS has a much wider array of attributes than HTML.  Disadvantages of CSS  Browser compatibility Browsers have varying levels of compliance with Style Sheets. This means that some Style Sheet features are supported and some aren't. To confuse things more, some browser manufacturers decide to come up with their own proprietary tags.