SlideShare a Scribd company logo
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
ļ‚— A Style Rule is composed of two parts: a selector
and a declaration.
TH {color: red;}.
ļ‚— The Selector indicates the element to which the
rule is applied.
ļ‚— The Declaration determines the property values of
a selector.
Selector
Declaration
Understanding Style Rules
ļ‚— The Property specifies a characteristic, such as
color, font-family, position, and is followed by a
colon (:).
ļ‚— The 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>
Output:
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>
Output:
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 css-ppt.pdf (20)

PPTX
Cascading Style Sheet
KushagraChadha1
Ā 
PDF
4. Web Technology CSS Basics-1
Jyoti Yadav
Ā 
PPT
css.ppt
SchoolEducationDepar
Ā 
PPTX
Cascading style sheet, CSS Box model, Table in CSS
SherinRappai
Ā 
PPTX
Beginners css tutorial for web designers
Singsys Pte Ltd
Ā 
PPT
Chapter 4a cascade style sheet css
Tesfaye Yenealem
Ā 
PPT
Chapter 3 - Web Design
tclanton4
Ā 
PPT
ch04-css-basics_final.ppt
GmachImen
Ā 
PPTX
Css types internal, external and inline (1)
Webtech Learning
Ā 
DOC
Css introduction
Sridhar P
Ā 
PDF
Web Typography
Shawn Calvert
Ā 
PPTX
Cascading style sheets
smithaps4
Ā 
PPT
IP - Lecture 6, 7 Chapter-3 (3).ppt
kassahungebrie
Ā 
PPTX
Unit 2 WT-CSS.pptx web technology project
abhiramhatwar
Ā 
PPTX
cascadingstylesheets,introduction.css styles-210909054722.pptx
hannahroseline2
Ā 
PPT
Css
Jafar Nesargi
Ā 
PPT
Css
Jafar Nesargi
Ā 
PPTX
Lecture-6.pptx
vishal choudhary
Ā 
PPT
cascading style sheet ppt
abhilashagupta
Ā 
PPTX
Cascading style sheets
smitha273566
Ā 
Cascading Style Sheet
KushagraChadha1
Ā 
4. Web Technology CSS Basics-1
Jyoti Yadav
Ā 
Cascading style sheet, CSS Box model, Table in CSS
SherinRappai
Ā 
Beginners css tutorial for web designers
Singsys Pte Ltd
Ā 
Chapter 4a cascade style sheet css
Tesfaye Yenealem
Ā 
Chapter 3 - Web Design
tclanton4
Ā 
ch04-css-basics_final.ppt
GmachImen
Ā 
Css types internal, external and inline (1)
Webtech Learning
Ā 
Css introduction
Sridhar P
Ā 
Web Typography
Shawn Calvert
Ā 
Cascading style sheets
smithaps4
Ā 
IP - Lecture 6, 7 Chapter-3 (3).ppt
kassahungebrie
Ā 
Unit 2 WT-CSS.pptx web technology project
abhiramhatwar
Ā 
cascadingstylesheets,introduction.css styles-210909054722.pptx
hannahroseline2
Ā 
Lecture-6.pptx
vishal choudhary
Ā 
cascading style sheet ppt
abhilashagupta
Ā 
Cascading style sheets
smitha273566
Ā 

Recently uploaded (20)

PPTX
Artificial Intelligence in Gastroentrology: Advancements and Future Presprec...
AyanHossain
Ā 
PDF
water conservation .pdf by Nandni Kumari XI C
Directorate of Education Delhi
Ā 
PPTX
YSPH VMOC Special Report - Measles Outbreak Southwest US 7-20-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
Ā 
PPTX
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
Ā 
PPTX
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
Ā 
PPT
DRUGS USED IN THERAPY OF SHOCK, Shock Therapy, Treatment or management of shock
Rajshri Ghogare
Ā 
PPTX
Orientation MOOCs on SWAYAM for Teachers
moocs1
Ā 
PDF
A guide to responding to Section C essay tasks for the VCE English Language E...
jpinnuck
Ā 
PPTX
Constitutional Design Civics Class 9.pptx
bikesh692
Ā 
PPTX
IDEAS AND EARLY STATES Social science pptx
NIRANJANASSURESH
Ā 
PPTX
HERNIA: INGUINAL HERNIA, UMBLICAL HERNIA.pptx
PRADEEP ABOTHU
Ā 
PDF
Stepwise procedure (Manually Submitted & Un Attended) Medical Devices Cases
MUHAMMAD SOHAIL
Ā 
PPTX
Qweb Templates and Operations in Odoo 18
Celine George
Ā 
PPTX
Nutrition Quiz bee for elementary 2025 1.pptx
RichellMarianoPugal
Ā 
PPTX
Rules and Regulations of Madhya Pradesh Library Part-I
SantoshKumarKori2
Ā 
PPTX
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
Ā 
PPTX
DIARRHOEA & DEHYDRATION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
Ā 
PPTX
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
Ā 
PPTX
How to Manage Resupply Subcontracting in Odoo 18
Celine George
Ā 
PPTX
Cybersecurity: How to Protect your Digital World from Hackers
vaidikpanda4
Ā 
Artificial Intelligence in Gastroentrology: Advancements and Future Presprec...
AyanHossain
Ā 
water conservation .pdf by Nandni Kumari XI C
Directorate of Education Delhi
Ā 
YSPH VMOC Special Report - Measles Outbreak Southwest US 7-20-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
Ā 
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
Ā 
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
Ā 
DRUGS USED IN THERAPY OF SHOCK, Shock Therapy, Treatment or management of shock
Rajshri Ghogare
Ā 
Orientation MOOCs on SWAYAM for Teachers
moocs1
Ā 
A guide to responding to Section C essay tasks for the VCE English Language E...
jpinnuck
Ā 
Constitutional Design Civics Class 9.pptx
bikesh692
Ā 
IDEAS AND EARLY STATES Social science pptx
NIRANJANASSURESH
Ā 
HERNIA: INGUINAL HERNIA, UMBLICAL HERNIA.pptx
PRADEEP ABOTHU
Ā 
Stepwise procedure (Manually Submitted & Un Attended) Medical Devices Cases
MUHAMMAD SOHAIL
Ā 
Qweb Templates and Operations in Odoo 18
Celine George
Ā 
Nutrition Quiz bee for elementary 2025 1.pptx
RichellMarianoPugal
Ā 
Rules and Regulations of Madhya Pradesh Library Part-I
SantoshKumarKori2
Ā 
INTESTINALPARASITES OR WORM INFESTATIONS.pptx
PRADEEP ABOTHU
Ā 
DIARRHOEA & DEHYDRATION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
Ā 
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
Ā 
How to Manage Resupply Subcontracting in Odoo 18
Celine George
Ā 
Cybersecurity: How to Protect your Digital World from Hackers
vaidikpanda4
Ā 
Ad

css-ppt.pdf

  • 1. 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 ļ‚— A Style Rule is composed of two parts: a selector and a declaration. TH {color: red;}. ļ‚— The Selector indicates the element to which the rule is applied. ļ‚— The Declaration determines the property values of a selector. Selector Declaration
  • 5. Understanding Style Rules ļ‚— The Property specifies a characteristic, such as color, font-family, position, and is followed by a colon (:). ļ‚— The 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> Output: 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> Output: 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.
  • 30. ļ‚— 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.