SlideShare a Scribd company logo
Introduction to CSS
What is CSS
• Cascading Style Sheets
• Contains the rules for the presentation of
HTML.
+ =
HTML CSS Web Page
• CSS was introduced to keep the
presentation information separate from
HTML markup (content).
Before CSS
• Initially Designers used presentation tags like (FONT, B, BR, TABLE
etc.) and spacers GIFs to control the design of web pages.
• Any modification in the design of websites
was a very difficult and boring task , as it
evolves manually editing every HTML
page.
Providing support for multiple browsers was a
difficult task.
Sources of Styles
Author (developer) Styles
• Inline Styles - As inline attribute “style” inside HTML tags
<div style=“font-weight: bold;”>I am bold</div>
• Embedded Styles - As embedded style tag with in HTML
document.
<html>
<head>
<title>Welcome to Vendio!</title>
<style>
.footer {
width:90%;
}
</style>
-------
</html>
• Linked Styles - Inside separate files with .css extension
<link rel="stylesheet" href=“external.css" type="text/css" />
Sources of Styles(contd.)
• User Style sheets
This file contains the user created styles .
[firefox profile folder]/ chrome/userContent-example.css
is the current user’s style sheet file for the firefox.
• Browser default style sheet
This file contains default styles for all users of a
browser
[firefox folder]/res/html.css is the default style sheet
file for the firefox.
CSS Selectors
• ID based ( #)
HTML CSS
<div id=“content”> #content {
Text width: 200px;
</div> }
ID selectors should be used with single elements.
Class based selector
• Class (.)
HTML CSS
<div class=“big”> .big{
Text width: 200px;
</div> }
<div>
<span class=“big”>some text </span>
</div>
Class based styles can be used by multiple HTML elements.
Tag based selectors
• Tag (Tag name)
HTML CSS
<div> DIV {
Text width: 200px;
</div> }
<div> SPAN {
<span>some text </span> font-size:130%;
</div> }
<span>some other text </span>
Grouping
• Multiple selectors can be grouped in a
single style declaration by using , .
H1, P , .main {
font-weight:bold;
}
Descendant selectors
Descendant selectors are used to select elements that
are descendants (not necessarily children) of another
element in the document tree.
HTML CSS
<div class=“abc”> DIV.abc P {
<div> font-weight:bold;
<P> }
Hello there!
</p>
</div>
</div>
Child selectors
A child selector is used to select an element that is a
direct child of another element (parent). Child selectors
will not select all descendants, only direct children.
HTML CSS
<div > DIV.abc > P {
<div class=“abc”> font-weight:bold;
<P> }
Hello there!
</p>
</div>
</div>
Universal selectors
Universal selectors are used to select any
element.
* {
color: blue;
}
Adjacent sibling selectors
Adjacent sibling selectors will select the
sibling immediately following an element.
DIV.abc + P {
font-weight: bold;
}
will work for
<div>
<div class=“abc”>Message</div>
<P>Hello there!</p>
</div>
Attribute selectors
Attribute selectors selects elements based
upon the attributes present in the HTML
Tags and their value.
IMG[src="small.gif"] {
border: 1px solid #000;
}
will work for
<img src=“small.gif” />
CSS Pseudo-classes
selector:pseudo-class { property: value }
:link
:visited } Link (A tag) related pseudo classes
:hover
:active
:after
:before
:first-child
:focus
:first-letter
:first-line
:lang
CSS Values
• Words: text-align:center;.
• Numerical values: Numerical values are usually
followed by a unit type.
font-size:12px;
12 is the numerical value and px is the unit type pixels.
– Absolute Values – in, pc, px, cm, mm, pt
– Relative Values – em, ex, %
• Color values: color:#336699 or color#369 or
rgb(255, 255, 255).
Categories of CSS properties
• Positioning and layout handling related.
• Background related properties.
• Font and text related
• Links related.
• Lists related.
• Table related.
Cascade
The CSS cascade assigns a weight
to each style rule. When several
rules apply, the one with the
greatest weight takes precedence.
Order of preference for various
styles:
– Default browser style sheet
(weakest)
– User style sheet
– Author style sheet
– Author embedded styles
– Author inline styles (strongest)
CSS Specificity
Rule 1. CSS File >> Embedded >> Inline
Rule 2. TAG >> class >> ID
Inheritance
• Styles that relate to text and appearance
are inherited by the descendant
elements.
• Styles that relate to the appearance of
boxes created by styling DIVs,
paragraphs, and other elements, such as
borders, padding, margins are not
inherited.
introduction to css cascading style sheets
introduction to css cascading style sheets
Refrences
• www.w3schools.com
• www.w3.org
• World wide web

More Related Content

PPT
Introduction to CSS
Amit Tyagi
 
PPTX
howcssworks-100207024009-phpapp01.pptx
RavneetSingh343801
 
PPTX
css v1 guru
GuruPada Das
 
PDF
2 introduction css
Jalpesh Vasa
 
PPT
Unit 2-CSS & Bootstrap.ppt
TusharTikia
 
PDF
CSS INTRODUCTION SLIDES WITH HTML CODE.pdf
Aasma13
 
PDF
4. Web Technology CSS Basics-1
Jyoti Yadav
 
PPTX
Module 2 CSS . cascading style sheet and its uses
BKReddy3
 
Introduction to CSS
Amit Tyagi
 
howcssworks-100207024009-phpapp01.pptx
RavneetSingh343801
 
css v1 guru
GuruPada Das
 
2 introduction css
Jalpesh Vasa
 
Unit 2-CSS & Bootstrap.ppt
TusharTikia
 
CSS INTRODUCTION SLIDES WITH HTML CODE.pdf
Aasma13
 
4. Web Technology CSS Basics-1
Jyoti Yadav
 
Module 2 CSS . cascading style sheet and its uses
BKReddy3
 

Similar to introduction to css cascading style sheets (20)

PDF
Introduction to CSS3
Seble Nigussie
 
PPTX
Cascading Styling Sheets(CSS) simple design language intended to transform th...
JebaRaj26
 
PPT
CSS Training in Bangalore
rajkamal560066
 
PPTX
Web technologies-course 03.pptx
Stefan Oprea
 
PPTX
Howcssworks 100207024009-phpapp01
Likitha47
 
PPTX
CSS
Akila Iroshan
 
PPT
Basic css
Gopinath Ambothi
 
PPTX
Lecture 3CSS part 1.pptx
GmachImen
 
PPTX
Css types internal, external and inline (1)
Webtech Learning
 
PPTX
uptu web technology unit 2 Css
Abhishek Kesharwani
 
PPT
IP - Lecture 6, 7 Chapter-3 (3).ppt
kassahungebrie
 
PDF
Chapterrr_8_Introduction to CSS.pptx.pdf
ankitayadavay123
 
PDF
Intro to HTML and CSS - Class 2 Slides
Heather Rock
 
PPT
How Cascading Style Sheets (CSS) Works
Amit Tyagi
 
PDF
ch-hguygureehuvnvdfduyertiuhrnhduuyfjh3.pdf
kasutaye192
 
PDF
Introduction to css
nikhilsh66131
 
PPTX
Css basics
mirza asif haider
 
Introduction to CSS3
Seble Nigussie
 
Cascading Styling Sheets(CSS) simple design language intended to transform th...
JebaRaj26
 
CSS Training in Bangalore
rajkamal560066
 
Web technologies-course 03.pptx
Stefan Oprea
 
Howcssworks 100207024009-phpapp01
Likitha47
 
Basic css
Gopinath Ambothi
 
Lecture 3CSS part 1.pptx
GmachImen
 
Css types internal, external and inline (1)
Webtech Learning
 
uptu web technology unit 2 Css
Abhishek Kesharwani
 
IP - Lecture 6, 7 Chapter-3 (3).ppt
kassahungebrie
 
Chapterrr_8_Introduction to CSS.pptx.pdf
ankitayadavay123
 
Intro to HTML and CSS - Class 2 Slides
Heather Rock
 
How Cascading Style Sheets (CSS) Works
Amit Tyagi
 
ch-hguygureehuvnvdfduyertiuhrnhduuyfjh3.pdf
kasutaye192
 
Introduction to css
nikhilsh66131
 
Css basics
mirza asif haider
 
Ad

More from SherwinSangalang3 (11)

PPTX
Module 3-Introduction to CSS (Chapter 3).pptx
SherwinSangalang3
 
PPT
introductiontohtmlcss-part2-120711042239-phpapp02.ppt
SherwinSangalang3
 
PDF
pdfcoffee.com_itel4a-web-systems-and-technologies-pdf-free.pdf
SherwinSangalang3
 
PPTX
Foundation_Logic_1.pptx discrete mathematics
SherwinSangalang3
 
PPT
AufEx4_12_06.ppt
SherwinSangalang3
 
PPT
AufEx4_02_04.ppt
SherwinSangalang3
 
PPT
AufEx4_02_01.ppt
SherwinSangalang3
 
PPT
AufEx4_01_03.ppt
SherwinSangalang3
 
PPT
AufEx4_01_02.ppt
SherwinSangalang3
 
PPT
AufEx4_01_01.ppt
SherwinSangalang3
 
PDF
CHAP1.pdf
SherwinSangalang3
 
Module 3-Introduction to CSS (Chapter 3).pptx
SherwinSangalang3
 
introductiontohtmlcss-part2-120711042239-phpapp02.ppt
SherwinSangalang3
 
pdfcoffee.com_itel4a-web-systems-and-technologies-pdf-free.pdf
SherwinSangalang3
 
Foundation_Logic_1.pptx discrete mathematics
SherwinSangalang3
 
AufEx4_12_06.ppt
SherwinSangalang3
 
AufEx4_02_04.ppt
SherwinSangalang3
 
AufEx4_02_01.ppt
SherwinSangalang3
 
AufEx4_01_03.ppt
SherwinSangalang3
 
AufEx4_01_02.ppt
SherwinSangalang3
 
AufEx4_01_01.ppt
SherwinSangalang3
 
Ad

Recently uploaded (20)

PDF
slide logistics CONVENIENCE STORES ..pdf
thuphuong0965195082
 
PPTX
The birth & Rise of python.pptx vaibhavd
vaibhavdobariyal79
 
PDF
Shayna Andrieze Yjasmin Goles - Your VA!
shaynagoles31
 
PDF
neurons-1hhdbbbsjndjnnbbdjndnnndj30501.pdf
Rahul954607
 
PDF
PowerPoint Presentation -- Jennifer Kyte -- 9786400311489 -- ade9381d14f65b06...
Adeel452922
 
PPTX
Artificial Intelligence presentation.pptx
snehajana651
 
PPTX
MALURI KISHORE-.pptxdsrhbcdsfvvghhhggggfff
sakthick46
 
PPTX
Riverfront Development_nashikcity_landscape
aditikoshley2
 
PDF
SS27 Women's Fashion Trend Book Peclers Paris
Peclers Paris
 
PPTX
UCSP-Powerpoint Presentation-Lesson-7.pptx
EmyMaquiling1
 
PPTX
UCSP-Quarter 1-Week 6-Powerpoint Presentation
EmyMaquiling1
 
PPTX
Introduction-to-Graphic-Design-and-Adobe-Photoshop.pptx
abdullahedpk
 
PDF
Fashion project1 kebaya reimagined slideshow
reysultane
 
PPTX
UCSP-Quarter 1-Week 5-Powerpoint Presentation
EmyMaquiling1
 
PPTX
原版定制TUBS毕业证(布伦瑞克工业大学毕业证书)成绩单修改定制学历成绩单
jicaaeb0
 
PPTX
Style and aesthetic about fashion lifestyle
Khushi Bera
 
PPTX
United Nation - CoUnited Nation - CoUnited Nation - Copy (2).pptx
mangalindanjerremyjh
 
PPTX
Brown Beige Vintage Style History Project Presentation.pptx
mb3030336
 
PDF
Biophilic Sound Design for Luxury Wellness Centers
Giorgio Marandola
 
PDF
First-Aid.pdfjavaghavavgahavavavbabavabba
meitohehe
 
slide logistics CONVENIENCE STORES ..pdf
thuphuong0965195082
 
The birth & Rise of python.pptx vaibhavd
vaibhavdobariyal79
 
Shayna Andrieze Yjasmin Goles - Your VA!
shaynagoles31
 
neurons-1hhdbbbsjndjnnbbdjndnnndj30501.pdf
Rahul954607
 
PowerPoint Presentation -- Jennifer Kyte -- 9786400311489 -- ade9381d14f65b06...
Adeel452922
 
Artificial Intelligence presentation.pptx
snehajana651
 
MALURI KISHORE-.pptxdsrhbcdsfvvghhhggggfff
sakthick46
 
Riverfront Development_nashikcity_landscape
aditikoshley2
 
SS27 Women's Fashion Trend Book Peclers Paris
Peclers Paris
 
UCSP-Powerpoint Presentation-Lesson-7.pptx
EmyMaquiling1
 
UCSP-Quarter 1-Week 6-Powerpoint Presentation
EmyMaquiling1
 
Introduction-to-Graphic-Design-and-Adobe-Photoshop.pptx
abdullahedpk
 
Fashion project1 kebaya reimagined slideshow
reysultane
 
UCSP-Quarter 1-Week 5-Powerpoint Presentation
EmyMaquiling1
 
原版定制TUBS毕业证(布伦瑞克工业大学毕业证书)成绩单修改定制学历成绩单
jicaaeb0
 
Style and aesthetic about fashion lifestyle
Khushi Bera
 
United Nation - CoUnited Nation - CoUnited Nation - Copy (2).pptx
mangalindanjerremyjh
 
Brown Beige Vintage Style History Project Presentation.pptx
mb3030336
 
Biophilic Sound Design for Luxury Wellness Centers
Giorgio Marandola
 
First-Aid.pdfjavaghavavgahavavavbabavabba
meitohehe
 

introduction to css cascading style sheets

  • 2. What is CSS • Cascading Style Sheets • Contains the rules for the presentation of HTML. + = HTML CSS Web Page • CSS was introduced to keep the presentation information separate from HTML markup (content).
  • 3. Before CSS • Initially Designers used presentation tags like (FONT, B, BR, TABLE etc.) and spacers GIFs to control the design of web pages.
  • 4. • Any modification in the design of websites was a very difficult and boring task , as it evolves manually editing every HTML page.
  • 5. Providing support for multiple browsers was a difficult task.
  • 6. Sources of Styles Author (developer) Styles • Inline Styles - As inline attribute “style” inside HTML tags <div style=“font-weight: bold;”>I am bold</div> • Embedded Styles - As embedded style tag with in HTML document. <html> <head> <title>Welcome to Vendio!</title> <style> .footer { width:90%; } </style> ------- </html> • Linked Styles - Inside separate files with .css extension <link rel="stylesheet" href=“external.css" type="text/css" />
  • 7. Sources of Styles(contd.) • User Style sheets This file contains the user created styles . [firefox profile folder]/ chrome/userContent-example.css is the current user’s style sheet file for the firefox. • Browser default style sheet This file contains default styles for all users of a browser [firefox folder]/res/html.css is the default style sheet file for the firefox.
  • 8. CSS Selectors • ID based ( #) HTML CSS <div id=“content”> #content { Text width: 200px; </div> } ID selectors should be used with single elements.
  • 9. Class based selector • Class (.) HTML CSS <div class=“big”> .big{ Text width: 200px; </div> } <div> <span class=“big”>some text </span> </div> Class based styles can be used by multiple HTML elements.
  • 10. Tag based selectors • Tag (Tag name) HTML CSS <div> DIV { Text width: 200px; </div> } <div> SPAN { <span>some text </span> font-size:130%; </div> } <span>some other text </span>
  • 11. Grouping • Multiple selectors can be grouped in a single style declaration by using , . H1, P , .main { font-weight:bold; }
  • 12. Descendant selectors Descendant selectors are used to select elements that are descendants (not necessarily children) of another element in the document tree. HTML CSS <div class=“abc”> DIV.abc P { <div> font-weight:bold; <P> } Hello there! </p> </div> </div>
  • 13. Child selectors A child selector is used to select an element that is a direct child of another element (parent). Child selectors will not select all descendants, only direct children. HTML CSS <div > DIV.abc > P { <div class=“abc”> font-weight:bold; <P> } Hello there! </p> </div> </div>
  • 14. Universal selectors Universal selectors are used to select any element. * { color: blue; }
  • 15. Adjacent sibling selectors Adjacent sibling selectors will select the sibling immediately following an element. DIV.abc + P { font-weight: bold; } will work for <div> <div class=“abc”>Message</div> <P>Hello there!</p> </div>
  • 16. Attribute selectors Attribute selectors selects elements based upon the attributes present in the HTML Tags and their value. IMG[src="small.gif"] { border: 1px solid #000; } will work for <img src=“small.gif” />
  • 17. CSS Pseudo-classes selector:pseudo-class { property: value } :link :visited } Link (A tag) related pseudo classes :hover :active :after :before :first-child :focus :first-letter :first-line :lang
  • 18. CSS Values • Words: text-align:center;. • Numerical values: Numerical values are usually followed by a unit type. font-size:12px; 12 is the numerical value and px is the unit type pixels. – Absolute Values – in, pc, px, cm, mm, pt – Relative Values – em, ex, % • Color values: color:#336699 or color#369 or rgb(255, 255, 255).
  • 19. Categories of CSS properties • Positioning and layout handling related. • Background related properties. • Font and text related • Links related. • Lists related. • Table related.
  • 20. Cascade The CSS cascade assigns a weight to each style rule. When several rules apply, the one with the greatest weight takes precedence. Order of preference for various styles: – Default browser style sheet (weakest) – User style sheet – Author style sheet – Author embedded styles – Author inline styles (strongest)
  • 21. CSS Specificity Rule 1. CSS File >> Embedded >> Inline Rule 2. TAG >> class >> ID
  • 22. Inheritance • Styles that relate to text and appearance are inherited by the descendant elements. • Styles that relate to the appearance of boxes created by styling DIVs, paragraphs, and other elements, such as borders, padding, margins are not inherited.