SlideShare a Scribd company logo
1
Introduction
CSS stands for Cascading Style Sheets
Style sheet language
Describe the look and formatting of a document
Styles define how to display HTML elements
Styles were added to HTML 4.0 to solve a problem
enable the separation of document content from
document presentation
2
CSS Syntax
A CSS rule set consists of a selector and a declaration
block
Selector
points to the HTML element you want to style
Declaration
contains one or more declarations separated by
semicolons
includes a property name and a value, separated by a
colon
3
CSS Syntax
4
CSS Example
p {color: red; text-align: center;}
body {background-image: url(“gla.jpg");}
h2 {
color: rgb(255,0,0);
}
a {
font-family: "Times New Roman", Times,
serif; }
5
CSS Selectors
The element Selector
selects elements based on the element name
The id Selector
uses the id attribute of an HTML tag to find the specific
element
Hash (#) character, followed by the name of the id
The class Selector
finds elements with the specific class
uses the HTML class attribute
Period (.) character, followed by the name of the class
6
Ex- Element Selector
<html>
<head>
<style>
p {text-align: center; color: red;}
</style>
</head>
<body>
<p>Every paragraph will be affected by the style.</p>
<p id="para1">Me too!</p>
<p>And me!</p>
</body>
</html>
7
Ex- ID Selector
<html>
<head>
<style>
#para1 {text-align: center; color: red;}
</style>
</head>
<body>
<p id="para1">Hello World!</p>
<p>This paragraph is not affected by the style.</p>
</body>
</html>
3/27/2019 8
Ex- Class Selector
<html>
<head>
<style>
p.center { text-align: center; color: red;}
</style>
</head>
<body>
<h1 class="center">This heading will not be affected</h1>
<p class="center">This paragraph will be red and center-
aligned.</p>
</body>
</html>
9
Ex- CLASS Selector
<html>
<head>
<style>
.center { text-align: center; color: red;}
</style>
</head>
<body>
<h1 class="center">Red and center-aligned heading</h1>
<p class="center">Red and center-aligned paragraph</p>
</body>
</html>
10
<html>
<head>
<style>
p.uppercase { text-transform: uppercase;}
p.lowercase { text-transform: lowercase;}
p.capitalize { text-transform: capitalize;}
</style>
</head>
<body>
<p class="uppercase">This is some text.</p>
<p class="lowercase">This is some text.</p>
<p class="capitalize">This is some text.</p>
</body>
</html>
11
Three Ways to Insert CSS
Internal style sheet
Within the html document
External style sheet
As an external CSS file with .css extension
Inline style
In the same line where we want to apply the
style
12
Internal Style Sheet
Used when a single document has a unique style
Defined in the head section of an HTML page
Defined within the <style> tag
Scope is up to the same document only
Every document has its own Internal CSS, if required.
13
External Style Sheet
 Ideal when the style is applied to many pages
 Changes the look of an entire Web site by changing
just one file
 Include a link to the style sheet with the <link> tag
 <link> tag goes inside the head section
 Attributes of <link> tag:
 rel
 type
 href
 CSS file is saved using .css extension
14
External Style Sheet Example
h1
{
color: red;
}
h6
{
Color: green;
}
Save it as “mystyle.css”
15
External Style Sheet Example
<html>
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
<body>
<h1> This is the biggest heading</h1>
<h6> This is the smallest heading</h6>
</body>
</html>
Save it as “abc.html”
16
Inline Style Sheet
adds the style attribute to the relevant tag
style attribute can contain any CSS property
<p style="color:green;margin-left:20px;“>
GLA
</p>
Will work for only the specified tag at that line only
17
Cascading order
All the styles will "cascade" into a new "virtual" style
sheet by the following rules:
Inline style (inside an HTML element)
(Highest priority)
Internal style sheet (in the head section)
External style sheet
 Browser default (Lowest priority)
Setting the Background
Properties used in background:
background-color: #ff00ff;
background-image: url(‘gla.jpg’);
background-repeat: no-repeat;
Other values can be repeat-x, repeat-y or repeat
background-position: top;
Other values are bottom, left or right
Ex- Background-Image
body {
background-color: yellow;
background-image: url("img_tree.png");
background-repeat: no-repeat;
background-position: right top;
}
20
Shorthand property
order of the property values is:
background-color
background-image
background-repeat
background-position
 It does not matter if one of the property values is missing, as long as the
ones that are present are in this order.
body {
background: #ffffff url("img_tree.png") no-repeat right top;
}
21
Meet u again…

More Related Content

PPT
Cascading Style Sheet | CSS
PPTX
Cascading Style Sheet
PPT
Cascading Style Sheet
PPTX
Introduction to CSS
PPTX
CSS Basics (Cascading Style Sheet)
PPTX
What is CSS?
DOC
Css introduction
Cascading Style Sheet | CSS
Cascading Style Sheet
Cascading Style Sheet
Introduction to CSS
CSS Basics (Cascading Style Sheet)
What is CSS?
Css introduction

What's hot (20)

PPT
CSS
ODP
PPTX
Week 12 CSS - Review from last week
PPSX
Introduction to css
PPT
Introduction to Cascading Style Sheets (CSS)
PPTX
Cascading Style Sheets (CSS)
PPT
Cascading Style Sheets
PPTX
Complete Lecture on Css presentation
PPTX
Cascading style sheets (CSS)
ODP
Introduction to css & its attributes with syntax
PPT
Cascading Style Sheets (CSS) help
PPT
Introduction to CSS
PPTX
Beginners css tutorial for web designers
PDF
Introduction to css
PPTX
Cascading Style Sheet (CSS)
PPTX
Introducing Cascading Style Sheets
PPTX
Css types internal, external and inline (1)
PPT
Css lecture notes
CSS
Week 12 CSS - Review from last week
Introduction to css
Introduction to Cascading Style Sheets (CSS)
Cascading Style Sheets (CSS)
Cascading Style Sheets
Complete Lecture on Css presentation
Cascading style sheets (CSS)
Introduction to css & its attributes with syntax
Cascading Style Sheets (CSS) help
Introduction to CSS
Beginners css tutorial for web designers
Introduction to css
Cascading Style Sheet (CSS)
Introducing Cascading Style Sheets
Css types internal, external and inline (1)
Css lecture notes
Ad

Similar to CSS (Cascading Style Sheet) (20)

PPTX
chitra
PPTX
CSS_Day_ONE (W3schools)
PPTX
Session v(css)
PPTX
Web technology Unit-II Part-C
PPTX
Css inclusion
PPTX
Lesson One Fourth Quarter Fourth Year High School CSS Modern Layout and Style
PDF
Cascading Style Sheets
PPTX
Css starting
DOC
Css introduction
PPTX
Lecture 3CSS part 1.pptx
PPTX
Lecture-6.pptx
PPTX
Lecture 9 CSS part 1.pptxType Classification
PDF
Css tutorial
PDF
TUTORIAL DE CSS 2.0
PPT
Chapter 4a cascade style sheet css
PPT
working with internet technologies using CSS
PPTX
Cascading style sheet, CSS Box model, Table in CSS
chitra
CSS_Day_ONE (W3schools)
Session v(css)
Web technology Unit-II Part-C
Css inclusion
Lesson One Fourth Quarter Fourth Year High School CSS Modern Layout and Style
Cascading Style Sheets
Css starting
Css introduction
Lecture 3CSS part 1.pptx
Lecture-6.pptx
Lecture 9 CSS part 1.pptxType Classification
Css tutorial
TUTORIAL DE CSS 2.0
Chapter 4a cascade style sheet css
working with internet technologies using CSS
Cascading style sheet, CSS Box model, Table in CSS
Ad

Recently uploaded (20)

PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Empathic Computing: Creating Shared Understanding
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Heart disease approach using modified random forest and particle swarm optimi...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
Encapsulation theory and applications.pdf
PDF
August Patch Tuesday
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Empathic Computing: Creating Shared Understanding
Unlocking AI with Model Context Protocol (MCP)
Building Integrated photovoltaic BIPV_UPV.pdf
Spectral efficient network and resource selection model in 5G networks
Per capita expenditure prediction using model stacking based on satellite ima...
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Programs and apps: productivity, graphics, security and other tools
Heart disease approach using modified random forest and particle swarm optimi...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
gpt5_lecture_notes_comprehensive_20250812015547.pdf
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Encapsulation theory and applications.pdf
August Patch Tuesday
Univ-Connecticut-ChatGPT-Presentaion.pdf
NewMind AI Weekly Chronicles - August'25-Week II
Mobile App Security Testing_ A Comprehensive Guide.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Digital-Transformation-Roadmap-for-Companies.pptx

CSS (Cascading Style Sheet)

  • 1. 1
  • 2. Introduction CSS stands for Cascading Style Sheets Style sheet language Describe the look and formatting of a document Styles define how to display HTML elements Styles were added to HTML 4.0 to solve a problem enable the separation of document content from document presentation 2
  • 3. CSS Syntax A CSS rule set consists of a selector and a declaration block Selector points to the HTML element you want to style Declaration contains one or more declarations separated by semicolons includes a property name and a value, separated by a colon 3
  • 5. CSS Example p {color: red; text-align: center;} body {background-image: url(“gla.jpg");} h2 { color: rgb(255,0,0); } a { font-family: "Times New Roman", Times, serif; } 5
  • 6. CSS Selectors The element Selector selects elements based on the element name The id Selector uses the id attribute of an HTML tag to find the specific element Hash (#) character, followed by the name of the id The class Selector finds elements with the specific class uses the HTML class attribute Period (.) character, followed by the name of the class 6
  • 7. Ex- Element Selector <html> <head> <style> p {text-align: center; color: red;} </style> </head> <body> <p>Every paragraph will be affected by the style.</p> <p id="para1">Me too!</p> <p>And me!</p> </body> </html> 7
  • 8. Ex- ID Selector <html> <head> <style> #para1 {text-align: center; color: red;} </style> </head> <body> <p id="para1">Hello World!</p> <p>This paragraph is not affected by the style.</p> </body> </html> 3/27/2019 8
  • 9. Ex- Class Selector <html> <head> <style> p.center { text-align: center; color: red;} </style> </head> <body> <h1 class="center">This heading will not be affected</h1> <p class="center">This paragraph will be red and center- aligned.</p> </body> </html> 9
  • 10. Ex- CLASS Selector <html> <head> <style> .center { text-align: center; color: red;} </style> </head> <body> <h1 class="center">Red and center-aligned heading</h1> <p class="center">Red and center-aligned paragraph</p> </body> </html> 10
  • 11. <html> <head> <style> p.uppercase { text-transform: uppercase;} p.lowercase { text-transform: lowercase;} p.capitalize { text-transform: capitalize;} </style> </head> <body> <p class="uppercase">This is some text.</p> <p class="lowercase">This is some text.</p> <p class="capitalize">This is some text.</p> </body> </html> 11
  • 12. Three Ways to Insert CSS Internal style sheet Within the html document External style sheet As an external CSS file with .css extension Inline style In the same line where we want to apply the style 12
  • 13. Internal Style Sheet Used when a single document has a unique style Defined in the head section of an HTML page Defined within the <style> tag Scope is up to the same document only Every document has its own Internal CSS, if required. 13
  • 14. External Style Sheet  Ideal when the style is applied to many pages  Changes the look of an entire Web site by changing just one file  Include a link to the style sheet with the <link> tag  <link> tag goes inside the head section  Attributes of <link> tag:  rel  type  href  CSS file is saved using .css extension 14
  • 15. External Style Sheet Example h1 { color: red; } h6 { Color: green; } Save it as “mystyle.css” 15
  • 16. External Style Sheet Example <html> <head> <link rel="stylesheet" type="text/css" href="mystyle.css"> </head> <body> <h1> This is the biggest heading</h1> <h6> This is the smallest heading</h6> </body> </html> Save it as “abc.html” 16
  • 17. Inline Style Sheet adds the style attribute to the relevant tag style attribute can contain any CSS property <p style="color:green;margin-left:20px;“> GLA </p> Will work for only the specified tag at that line only 17
  • 18. Cascading order All the styles will "cascade" into a new "virtual" style sheet by the following rules: Inline style (inside an HTML element) (Highest priority) Internal style sheet (in the head section) External style sheet  Browser default (Lowest priority)
  • 19. Setting the Background Properties used in background: background-color: #ff00ff; background-image: url(‘gla.jpg’); background-repeat: no-repeat; Other values can be repeat-x, repeat-y or repeat background-position: top; Other values are bottom, left or right
  • 20. Ex- Background-Image body { background-color: yellow; background-image: url("img_tree.png"); background-repeat: no-repeat; background-position: right top; } 20
  • 21. Shorthand property order of the property values is: background-color background-image background-repeat background-position  It does not matter if one of the property values is missing, as long as the ones that are present are in this order. body { background: #ffffff url("img_tree.png") no-repeat right top; } 21