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

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
 

Similar to Css module1 (20)

PPTX
CSS (Cascading Style Sheet)
Harshit Srivastava
 
PPTX
Cascading Style Sheet
KushagraChadha1
 
PPTX
cascading style sheets- About cascading style sheets on the selectors
JayanthiM19
 
PPTX
chitra
sweet chitra
 
PPTX
CSS Basics (Cascading Style Sheet)
Ajay Khatri
 
PPT
Chapter 4a cascade style sheet css
Tesfaye Yenealem
 
PPTX
Cascading style sheet, CSS Box model, Table in CSS
SherinRappai
 
PPTX
Introduction to CSS
Shehzad Yaqoob
 
PPT
css-presentation.ppt
prathur68
 
PPTX
Slides-Online-Week2-Website-Frontend-CSS.pptx
ahmadraza72678
 
PDF
Unit III CSS & JAVA Script.pdf
meghana092
 
PPTX
Cascading style sheet an introduction
Himanshu Pathak
 
PPT
ch04-css-basics_final.ppt
GmachImen
 
PPT
CSS-part-1.ppt
AshwaniKumarYadav19
 
PPTX
LIS3353 SP12 Week 13
Amanda Case
 
PPTX
Ifi7174 lesson2
Sónia
 
PPTX
Lecture-6.pptx
vishal choudhary
 
PPTX
4_css_intro.pptx. this ppt is based on css which is the required of web deve...
sindwanigripsi
 
CSS (Cascading Style Sheet)
Harshit Srivastava
 
Cascading Style Sheet
KushagraChadha1
 
cascading style sheets- About cascading style sheets on the selectors
JayanthiM19
 
chitra
sweet chitra
 
CSS Basics (Cascading Style Sheet)
Ajay Khatri
 
Chapter 4a cascade style sheet css
Tesfaye Yenealem
 
Cascading style sheet, CSS Box model, Table in CSS
SherinRappai
 
Introduction to CSS
Shehzad Yaqoob
 
css-presentation.ppt
prathur68
 
Slides-Online-Week2-Website-Frontend-CSS.pptx
ahmadraza72678
 
Unit III CSS & JAVA Script.pdf
meghana092
 
Cascading style sheet an introduction
Himanshu Pathak
 
ch04-css-basics_final.ppt
GmachImen
 
CSS-part-1.ppt
AshwaniKumarYadav19
 
LIS3353 SP12 Week 13
Amanda Case
 
Ifi7174 lesson2
Sónia
 
Lecture-6.pptx
vishal choudhary
 
4_css_intro.pptx. this ppt is based on css which is the required of web deve...
sindwanigripsi
 
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
 
Ad

Recently uploaded (20)

PPTX
Day2 B2 Best.pptx
helenjenefa1
 
PDF
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
PDF
Electrical Engineer operation Supervisor
ssaruntatapower143
 
PPTX
Hashing Introduction , hash functions and techniques
sailajam21
 
DOCX
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
PDF
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
PDF
Ethics and Trustworthy AI in Healthcare – Governing Sensitive Data, Profiling...
AlqualsaDIResearchGr
 
PPTX
artificial intelligence applications in Geomatics
NawrasShatnawi1
 
PPTX
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
PPTX
Depth First Search Algorithm in 🧠 DFS in Artificial Intelligence (AI)
rafeeqshaik212002
 
PDF
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
PDF
Zilliz Cloud Demo for performance and scale
Zilliz
 
PPTX
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
PDF
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
PPTX
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
PPTX
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 
PPTX
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
PPTX
Shinkawa Proposal to meet Vibration API670.pptx
AchmadBashori2
 
PPTX
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
PDF
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
Day2 B2 Best.pptx
helenjenefa1
 
International Journal of Information Technology Convergence and services (IJI...
ijitcsjournal4
 
Electrical Engineer operation Supervisor
ssaruntatapower143
 
Hashing Introduction , hash functions and techniques
sailajam21
 
CS-802 (A) BDH Lab manual IPS Academy Indore
thegodhimself05
 
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
Ethics and Trustworthy AI in Healthcare – Governing Sensitive Data, Profiling...
AlqualsaDIResearchGr
 
artificial intelligence applications in Geomatics
NawrasShatnawi1
 
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
Depth First Search Algorithm in 🧠 DFS in Artificial Intelligence (AI)
rafeeqshaik212002
 
MAD Unit - 1 Introduction of Android IT Department
JappanMavani
 
Zilliz Cloud Demo for performance and scale
Zilliz
 
GitOps_Without_K8s_Training_detailed git repository
DanialHabibi2
 
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
Mechanical Design of shell and tube heat exchangers as per ASME Sec VIII Divi...
shahveer210504
 
The Role of Information Technology in Environmental Protectio....pptx
nallamillisriram
 
Shinkawa Proposal to meet Vibration API670.pptx
AchmadBashori2
 
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 

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