SlideShare a Scribd company logo
Cascading style sheets (CSS)
-Varsha Kumari
9/9/2019 1
DHTML
• DHTML is the programming language that is
embedded in HTML and helps in creation of dynamic
web pages using a combination of the static markup
language HTML, a client side scripting language (such
as JavaScript) and the style definition language
Cascading Style Sheets.
• HTML specifies a web page’s elements like table,
frame, paragraph, list etc.
• CSS can be used for formatting some features of
those elements like element’s size, color, position
etc
9/9/2019 2
Introduction
What is CSS?
CSS stands for Cascading Style Sheets
Style sheet language
Describe the looks and formatting of a
document
Styles define how to display HTML elements
enable the separation of document content
from document presentation
9/9/2019 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
9/9/2019 4
CSS Syntax
9/9/2019 5
CSS Example
p {color: red; text-align: center; font-
size:30px; text-transform: uppercase;}
body {background-image: url(“gla.jpg");
margin-left:20px;}
td{background-color:”red” ;}
h2 { color: rgb(255,0,0); }
p { font-family: "Times New Roman“; } 6
• div {
border: 1px solid black;
margin: 100px 150px 100px 80px;
background-color: lightblue;
• }
9/9/2019 7
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
9/9/2019 8
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.
9/9/2019 9
abc.html
<html>
<head>
<style>
p {text-align: center; color: red;}
h1{color: red; text-transform: lowercase;}
</style>
</head>
<body>
<p>Every paragraph will be affected by the style.</p>
<h1Me too!</h1>
<p>And me!</p>
</body>
</html> Save it as “abc.html”
9/9/2019 10
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
9/9/2019 11
External Style Sheet Example
H1 {color: red;}
H6{Color: green;}
Save it as “mystyle.css”
9/9/2019 12
External Style Sheet Example (Contd.)
<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”
9/9/2019 13
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; text-
transform: uppercase;” >
GLA University
</p>
Will work for only the specified tag at that line
only
9/9/2019 14
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)
9/9/2019 15
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
9/9/2019 16
Example of 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>
9/9/2019 17
Example of 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>
9/9/2019 18
Another Example of ID 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/9/2019 19
Example of 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>
9/9/2019 20
Another Example of CLASS Selector
<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>9/9/2019 21
Contextual Selectors:
• The SPAN element gives structure and context to any
inline content in a document.
<html><head>
<style type = “text/css”>
p {background-color: rgb(200,0,255)}
p.A {background-color: rgb(250,0,255)}
.B{background-color: rgb(0,133,0)}
</style></head>
<body>
<p> welcome to </p>
<p class="A">Welcome to <span class = "B"> GLA
University</span> Mathura.</p>
<p class="B">Uttar Pradesh</p>
</body></html>9/9/2019 22
Document Object Model(DOM):
• The components of web pages are represented by objects that are
organized in hierarchical structure(parent-child relationship), called
DOM
• These objects have properties and methods that can be used to
work with web pages.
• For a script to communicate one of the objects it must know the
path through the hierarchy to reach the object, so it can call one of
the methods or set one of its property values.
• Ex
• document.form1.firstname.value
• Document.bgcolor=“lightgreen”
• Document.title=“new title is my second web page”
• Document.write(“<h1>hello</h1>”);
9/9/2019 23
Example of DOM
9/9/2019 24
Browser Object Model
• The browser object model (BOM) is a hierarchy of
browser objects that are used to manipulate methods
and properties associated with the Web browser itself.
• BOM include the window object, navigator object,
screen object, history, location object, and the
document object.
• Top of the object hierarchy is the windows object.
• The Document Object consists of objects that are used
to manipulate methods and properties of the
document or Web page loaded in the browser window.
9/9/2019 25
9/9/2019 26
9/9/2019 27

More Related Content

PPT
Html mod1
VARSHAKUMARI49
 
PPT
Cascading style sheet
VARSHAKUMARI49
 
PPTX
Css mod1
VARSHAKUMARI49
 
PPTX
Html
NithyaD5
 
DOC
Css introduction
vishnu murthy
 
PPTX
HTML
shaiksafi1
 
PDF
Html tutorials by www.dmdiploma.com
ShwetaAggarwal56
 
Html mod1
VARSHAKUMARI49
 
Cascading style sheet
VARSHAKUMARI49
 
Css mod1
VARSHAKUMARI49
 
Html
NithyaD5
 
Css introduction
vishnu murthy
 
Html tutorials by www.dmdiploma.com
ShwetaAggarwal56
 

What's hot (19)

PPTX
Css
Hemant Saini
 
PPTX
Chapter 6 html
home
 
ODP
CSS Basics
Sanjeev Kumar
 
PPT
HTML basics
Akhil Kaushik
 
PDF
3. tutorial html web desain
faizibra
 
PPTX
CSS - LinkedIn
Gino Louie Peña, ITIL®,MOS®
 
PPTX
HTML
Toni Kolev
 
PDF
Introduction to html
eShikshak
 
PPTX
HTML Tutorials
Arvind Kumar
 
PPTX
Web Page Designing Using HTML
Ashmita Tuition Center
 
PPT
HTML By K.Sasidhar
Sasidhar Kothuru
 
PPT
CSS Basics
WordPress Memphis
 
PPT
Introduction to css by programmerblog.net
Programmer Blog
 
PPT
Html project
arsh7511
 
PPTX
Web Application and HTML Summary
Fernando Torres
 
PDF
Web development using html 5
Anjan Mahanta
 
PPTX
Elements of html powerpoint
Anastasia1993
 
Chapter 6 html
home
 
CSS Basics
Sanjeev Kumar
 
HTML basics
Akhil Kaushik
 
3. tutorial html web desain
faizibra
 
Introduction to html
eShikshak
 
HTML Tutorials
Arvind Kumar
 
Web Page Designing Using HTML
Ashmita Tuition Center
 
HTML By K.Sasidhar
Sasidhar Kothuru
 
CSS Basics
WordPress Memphis
 
Introduction to css by programmerblog.net
Programmer Blog
 
Html project
arsh7511
 
Web Application and HTML Summary
Fernando Torres
 
Web development using html 5
Anjan Mahanta
 
Elements of html powerpoint
Anastasia1993
 
Ad

Similar to Css module1 (20)

PPTX
Lecture-6.pptx
vishal choudhary
 
PPTX
Cascading style sheet, CSS Box model, Table in CSS
SherinRappai
 
PPTX
Introduction to CSS
Folasade Adedeji
 
PDF
CSS notes
Rajendra Prasad
 
PDF
Introduction to css
Joseph Gabriel
 
PPT
IP - Lecture 6, 7 Chapter-3 (3).ppt
kassahungebrie
 
PPTX
properties of css.pptx power pointpresentation
Coderkids
 
PPTX
What is CSS.pptx power point presentation
Coderkids
 
PPTX
Unitegergergegegegetgegegegegegeg-2-CSS.pptx
VikasTuwar1
 
PDF
cascading style sheets ppt.sildeshower phone view
kedaringle994
 
DOCX
CSS Tutorial For Basic Students Studying
nirmala119429
 
PPTX
Turorial css
Muhammad Syifa
 
PPT
Using Cascading Style Sheets2
Sutinder Mann
 
PPT
Using Templates And Cascading Style Sheets10
Sutinder Mann
 
PDF
Cascading Style Sheets
Mukesh Tekwani
 
PDF
TUTORIAL DE CSS 2.0
Vladimir Valencia
 
PPT
cse labpractical.ppt
NividitaDarwai
 
PPTX
Css starting
Rahul Dihora
 
PPTX
CSS (Cascading Style Sheet)
Harshit Srivastava
 
Lecture-6.pptx
vishal choudhary
 
Cascading style sheet, CSS Box model, Table in CSS
SherinRappai
 
Introduction to CSS
Folasade Adedeji
 
CSS notes
Rajendra Prasad
 
Introduction to css
Joseph Gabriel
 
IP - Lecture 6, 7 Chapter-3 (3).ppt
kassahungebrie
 
properties of css.pptx power pointpresentation
Coderkids
 
What is CSS.pptx power point presentation
Coderkids
 
Unitegergergegegegetgegegegegegeg-2-CSS.pptx
VikasTuwar1
 
cascading style sheets ppt.sildeshower phone view
kedaringle994
 
CSS Tutorial For Basic Students Studying
nirmala119429
 
Turorial css
Muhammad Syifa
 
Using Cascading Style Sheets2
Sutinder Mann
 
Using Templates And Cascading Style Sheets10
Sutinder Mann
 
Cascading Style Sheets
Mukesh Tekwani
 
TUTORIAL DE CSS 2.0
Vladimir Valencia
 
cse labpractical.ppt
NividitaDarwai
 
Css starting
Rahul Dihora
 
CSS (Cascading Style Sheet)
Harshit Srivastava
 
Ad

More from VARSHAKUMARI49 (13)

PPT
28,29. procedures subprocedure,type checking functions in VBScript
VARSHAKUMARI49
 
PPT
30,31,32,33. decision and loop statements in vbscript
VARSHAKUMARI49
 
PPT
27. mathematical, date and time functions in VB Script
VARSHAKUMARI49
 
PPT
Introduction to web technology
VARSHAKUMARI49
 
PPT
Database normalization
VARSHAKUMARI49
 
PPT
Joins
VARSHAKUMARI49
 
PPT
Sub queries
VARSHAKUMARI49
 
PPT
Introduction to sql
VARSHAKUMARI49
 
PPT
Vbscript
VARSHAKUMARI49
 
PPT
Js mod1
VARSHAKUMARI49
 
PPT
Register counters.readonly
VARSHAKUMARI49
 
PPT
Sorting.ppt read only
VARSHAKUMARI49
 
PPT
Hashing
VARSHAKUMARI49
 
28,29. procedures subprocedure,type checking functions in VBScript
VARSHAKUMARI49
 
30,31,32,33. decision and loop statements in vbscript
VARSHAKUMARI49
 
27. mathematical, date and time functions in VB Script
VARSHAKUMARI49
 
Introduction to web technology
VARSHAKUMARI49
 
Database normalization
VARSHAKUMARI49
 
Sub queries
VARSHAKUMARI49
 
Introduction to sql
VARSHAKUMARI49
 
Vbscript
VARSHAKUMARI49
 
Register counters.readonly
VARSHAKUMARI49
 
Sorting.ppt read only
VARSHAKUMARI49
 

Recently uploaded (20)

PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
sangeethamtech26
 
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
quakeplayz54
 
PDF
Structs to JSON How Go Powers REST APIs.pdf
Emily Achieng
 
PPTX
Simulation of electric circuit laws using tinkercad.pptx
VidhyaH3
 
PPTX
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
PDF
Principles of Food Science and Nutritions
Dr. Yogesh Kumar Kosariya
 
PDF
Chad Ayach - A Versatile Aerospace Professional
Chad Ayach
 
PPTX
Module_II_Data_Science_Project_Management.pptx
anshitanarain
 
PPTX
Chapter----five---Resource Recovery.pptx
078bce110prashant
 
PPTX
Production of bioplastic from fruit peels.pptx
alwingeorgealwingeor
 
PPTX
Practice Questions on recent development part 1.pptx
JaspalSingh402
 
PDF
6th International Conference on Artificial Intelligence and Machine Learning ...
gerogepatton
 
PPTX
Edge to Cloud Protocol HTTP WEBSOCKET MQTT-SN MQTT.pptx
dhanashri894551
 
PDF
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hatem173148
 
PDF
오픈소스 LLM, vLLM으로 Production까지 (Instruct.KR Summer Meetup, 2025)
Hyogeun Oh
 
PPTX
EE3303-EM-I 25.7.25 electrical machines.pptx
Nagen87
 
PDF
2010_Book_EnvironmentalBioengineering (1).pdf
EmilianoRodriguezTll
 
PDF
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
PDF
flutter Launcher Icons, Splash Screens & Fonts
Ahmed Mohamed
 
Strings in CPP - Strings in C++ are sequences of characters used to store and...
sangeethamtech26
 
Lesson 3_Tessellation.pptx finite Mathematics
quakeplayz54
 
Structs to JSON How Go Powers REST APIs.pdf
Emily Achieng
 
Simulation of electric circuit laws using tinkercad.pptx
VidhyaH3
 
Module2 Data Base Design- ER and NF.pptx
gomathisankariv2
 
Principles of Food Science and Nutritions
Dr. Yogesh Kumar Kosariya
 
Chad Ayach - A Versatile Aerospace Professional
Chad Ayach
 
Module_II_Data_Science_Project_Management.pptx
anshitanarain
 
Chapter----five---Resource Recovery.pptx
078bce110prashant
 
Production of bioplastic from fruit peels.pptx
alwingeorgealwingeor
 
Practice Questions on recent development part 1.pptx
JaspalSingh402
 
6th International Conference on Artificial Intelligence and Machine Learning ...
gerogepatton
 
Edge to Cloud Protocol HTTP WEBSOCKET MQTT-SN MQTT.pptx
dhanashri894551
 
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hatem173148
 
오픈소스 LLM, vLLM으로 Production까지 (Instruct.KR Summer Meetup, 2025)
Hyogeun Oh
 
EE3303-EM-I 25.7.25 electrical machines.pptx
Nagen87
 
2010_Book_EnvironmentalBioengineering (1).pdf
EmilianoRodriguezTll
 
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
flutter Launcher Icons, Splash Screens & Fonts
Ahmed Mohamed
 

Css module1

  • 1. Cascading style sheets (CSS) -Varsha Kumari 9/9/2019 1
  • 2. DHTML • DHTML is the programming language that is embedded in HTML and helps in creation of dynamic web pages using a combination of the static markup language HTML, a client side scripting language (such as JavaScript) and the style definition language Cascading Style Sheets. • HTML specifies a web page’s elements like table, frame, paragraph, list etc. • CSS can be used for formatting some features of those elements like element’s size, color, position etc 9/9/2019 2
  • 3. Introduction What is CSS? CSS stands for Cascading Style Sheets Style sheet language Describe the looks and formatting of a document Styles define how to display HTML elements enable the separation of document content from document presentation 9/9/2019 3
  • 4. 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 9/9/2019 4
  • 6. CSS Example p {color: red; text-align: center; font- size:30px; text-transform: uppercase;} body {background-image: url(“gla.jpg"); margin-left:20px;} td{background-color:”red” ;} h2 { color: rgb(255,0,0); } p { font-family: "Times New Roman“; } 6
  • 7. • div { border: 1px solid black; margin: 100px 150px 100px 80px; background-color: lightblue; • } 9/9/2019 7
  • 8. 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 9/9/2019 8
  • 9. 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. 9/9/2019 9
  • 10. abc.html <html> <head> <style> p {text-align: center; color: red;} h1{color: red; text-transform: lowercase;} </style> </head> <body> <p>Every paragraph will be affected by the style.</p> <h1Me too!</h1> <p>And me!</p> </body> </html> Save it as “abc.html” 9/9/2019 10
  • 11. 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 9/9/2019 11
  • 12. External Style Sheet Example H1 {color: red;} H6{Color: green;} Save it as “mystyle.css” 9/9/2019 12
  • 13. External Style Sheet Example (Contd.) <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” 9/9/2019 13
  • 14. 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; text- transform: uppercase;” > GLA University </p> Will work for only the specified tag at that line only 9/9/2019 14
  • 15. 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) 9/9/2019 15
  • 16. 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 9/9/2019 16
  • 17. Example of 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> 9/9/2019 17
  • 18. Example of 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> 9/9/2019 18
  • 19. Another Example of ID 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/9/2019 19
  • 20. Example of 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> 9/9/2019 20
  • 21. Another Example of CLASS Selector <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>9/9/2019 21
  • 22. Contextual Selectors: • The SPAN element gives structure and context to any inline content in a document. <html><head> <style type = “text/css”> p {background-color: rgb(200,0,255)} p.A {background-color: rgb(250,0,255)} .B{background-color: rgb(0,133,0)} </style></head> <body> <p> welcome to </p> <p class="A">Welcome to <span class = "B"> GLA University</span> Mathura.</p> <p class="B">Uttar Pradesh</p> </body></html>9/9/2019 22
  • 23. Document Object Model(DOM): • The components of web pages are represented by objects that are organized in hierarchical structure(parent-child relationship), called DOM • These objects have properties and methods that can be used to work with web pages. • For a script to communicate one of the objects it must know the path through the hierarchy to reach the object, so it can call one of the methods or set one of its property values. • Ex • document.form1.firstname.value • Document.bgcolor=“lightgreen” • Document.title=“new title is my second web page” • Document.write(“<h1>hello</h1>”); 9/9/2019 23
  • 25. Browser Object Model • The browser object model (BOM) is a hierarchy of browser objects that are used to manipulate methods and properties associated with the Web browser itself. • BOM include the window object, navigator object, screen object, history, location object, and the document object. • Top of the object hierarchy is the windows object. • The Document Object consists of objects that are used to manipulate methods and properties of the document or Web page loaded in the browser window. 9/9/2019 25