SlideShare a Scribd company logo
Introduction to CSS
     By Amit Tyagi
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
Introduction to CSS
Refrences
• www.w3schools.com
• www.w3.org
• World wide web

More Related Content

What's hot (20)

PPTX
Html5 semantics
Webtech Learning
 
PPT
Hyperlinks in HTML
Aarti P
 
PPTX
Css types internal, external and inline (1)
Webtech Learning
 
PPTX
Css selectors
Parth Trivedi
 
PPTX
HTML Forms
Ravinder Kamboj
 
PPTX
Basic html structure
Jhaun Paul Enriquez
 
PPTX
Html ppt
santosh lamba
 
PPTX
Css box-model
Webtech Learning
 
PPT
cascading style sheet ppt
abhilashagupta
 
PDF
Bootstrap
Jadson Santos
 
PPT
CSS for Beginners
Amit Kumar Singh
 
PPTX
HTML
Akash Varaiya
 
PPTX
html-css
Dhirendra Chauhan
 
PDF
WEB I - 01 - Introduction to Web Development
Randy Connolly
 
PPTX
css.ppt
bhasula
 
PPSX
Javascript variables and datatypes
Varun C M
 
PDF
Web Development with HTML5, CSS3 & JavaScript
Edureka!
 
PDF
Html frames
eShikshak
 
PPTX
Html5 tutorial for beginners
Singsys Pte Ltd
 
Html5 semantics
Webtech Learning
 
Hyperlinks in HTML
Aarti P
 
Css types internal, external and inline (1)
Webtech Learning
 
Css selectors
Parth Trivedi
 
HTML Forms
Ravinder Kamboj
 
Basic html structure
Jhaun Paul Enriquez
 
Html ppt
santosh lamba
 
Css box-model
Webtech Learning
 
cascading style sheet ppt
abhilashagupta
 
Bootstrap
Jadson Santos
 
CSS for Beginners
Amit Kumar Singh
 
html-css
Dhirendra Chauhan
 
WEB I - 01 - Introduction to Web Development
Randy Connolly
 
css.ppt
bhasula
 
Javascript variables and datatypes
Varun C M
 
Web Development with HTML5, CSS3 & JavaScript
Edureka!
 
Html frames
eShikshak
 
Html5 tutorial for beginners
Singsys Pte Ltd
 

Viewers also liked (10)

PPT
CSS ppt
Sanmuga Nathan
 
PDF
HTML CSS Basics
Mai Moustafa
 
PPT
Html Ppt
vijayanit
 
PPT
Introduction to Cascading Style Sheets (CSS)
Chris Poteet
 
PPT
Css Ppt
Hema Prasanth
 
PPTX
Cookie and session
Aashish Ghale
 
PPT
How Cascading Style Sheets (CSS) Works
Amit Tyagi
 
PPT
Introduction to html
vikasgaur31
 
KEY
HTML presentation for beginners
jeroenvdmeer
 
PPTX
Cookies!
kellimccabe
 
CSS ppt
Sanmuga Nathan
 
HTML CSS Basics
Mai Moustafa
 
Html Ppt
vijayanit
 
Introduction to Cascading Style Sheets (CSS)
Chris Poteet
 
Css Ppt
Hema Prasanth
 
Cookie and session
Aashish Ghale
 
How Cascading Style Sheets (CSS) Works
Amit Tyagi
 
Introduction to html
vikasgaur31
 
HTML presentation for beginners
jeroenvdmeer
 
Cookies!
kellimccabe
 
Ad

Similar to Introduction to CSS (20)

PDF
introduction to css cascading style sheets
SherwinSangalang3
 
PPT
introductiontohtmlcss-part2-120711042239-phpapp02.ppt
SherwinSangalang3
 
PPTX
css v1 guru
GuruPada Das
 
PPTX
Howcssworks 100207024009-phpapp01
Likitha47
 
PPTX
howcssworks-100207024009-phpapp01.pptx
RavneetSingh343801
 
PPTX
Cascading Styling Sheets(CSS) simple design language intended to transform th...
JebaRaj26
 
PDF
2 introduction css
Jalpesh Vasa
 
KEY
Artdm171 Week5 Css
Gilbert Guerrero
 
PPTX
Internet tech &amp; web prog. p4,5
Taymoor Nazmy
 
PPT
CSS Overview
Doncho Minkov
 
PPTX
Introduction to Wed System And Technologies (1).pptx
AmeerHamza183012
 
PPTX
Web Development - Lecture 5
Syed Shahzaib Sohail
 
PPTX
Css basics
ASIT
 
PPTX
Introduction to CSS.pptx web for web web
compengwaelalahmar
 
PDF
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
Erin M. Kidwell
 
PPTX
Css ms megha
Megha Gupta
 
PPT
Css
Sumit Gupta
 
PDF
4. Web Technology CSS Basics-1
Jyoti Yadav
 
PPTX
Unit-3-CSS-BWT.pptx
Tanu524249
 
introduction to css cascading style sheets
SherwinSangalang3
 
introductiontohtmlcss-part2-120711042239-phpapp02.ppt
SherwinSangalang3
 
css v1 guru
GuruPada Das
 
Howcssworks 100207024009-phpapp01
Likitha47
 
howcssworks-100207024009-phpapp01.pptx
RavneetSingh343801
 
Cascading Styling Sheets(CSS) simple design language intended to transform th...
JebaRaj26
 
2 introduction css
Jalpesh Vasa
 
Artdm171 Week5 Css
Gilbert Guerrero
 
Internet tech &amp; web prog. p4,5
Taymoor Nazmy
 
CSS Overview
Doncho Minkov
 
Introduction to Wed System And Technologies (1).pptx
AmeerHamza183012
 
Web Development - Lecture 5
Syed Shahzaib Sohail
 
Css basics
ASIT
 
Introduction to CSS.pptx web for web web
compengwaelalahmar
 
Girl Develop It Cincinnati: Intro to HTML/CSS Class 2
Erin M. Kidwell
 
Css ms megha
Megha Gupta
 
4. Web Technology CSS Basics-1
Jyoti Yadav
 
Unit-3-CSS-BWT.pptx
Tanu524249
 
Ad

Recently uploaded (20)

PDF
Nanotechnology and Functional Foods Effective Delivery of Bioactive Ingredien...
rmswlwcxai8321
 
PPTX
Photo chemistry Power Point Presentation
mprpgcwa2024
 
PDF
Learning Styles Inventory for Senior High School Students
Thelma Villaflores
 
PDF
Andreas Schleicher_Teaching Compass_Education 2040.pdf
EduSkills OECD
 
PDF
The Power of Compound Interest (Stanford Initiative for Financial Decision-Ma...
Stanford IFDM
 
PPTX
Elo the HeroTHIS IS A STORY ABOUT A BOY WHO SAVED A LITTLE GOAT .pptx
JoyIPanos
 
PPTX
How to Add New Item in CogMenu in Odoo 18
Celine George
 
PDF
Wikinomics How Mass Collaboration Changes Everything Don Tapscott
wcsqyzf5909
 
PPTX
Peer Teaching Observations During School Internship
AjayaMohanty7
 
PDF
Lesson 1 : Science and the Art of Geography Ecosystem
marvinnbustamante1
 
PDF
Our Guide to the July 2025 USPS® Rate Change
Postal Advocate Inc.
 
PPTX
How to Setup Automatic Reordering Rule in Odoo 18 Inventory
Celine George
 
PPT
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
ErlizaRosete
 
PPTX
SYMPATHOMIMETICS[ADRENERGIC AGONISTS] pptx
saip95568
 
PPTX
Elo the Hero is an story about a young boy who became hero.
TeacherEmily1
 
PDF
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
nabilahk908
 
PDF
COM and NET Component Services 1st Edition Juval Löwy
kboqcyuw976
 
PDF
DIGESTION OF CARBOHYDRATES ,PROTEINS AND LIPIDS
raviralanaresh2
 
PDF
CAD25 Gbadago and Fafa Presentation Revised-Aston Business School, UK.pdf
Kweku Zurek
 
PDF
Free eBook ~100 Common English Proverbs (ebook) pdf.pdf
OH TEIK BIN
 
Nanotechnology and Functional Foods Effective Delivery of Bioactive Ingredien...
rmswlwcxai8321
 
Photo chemistry Power Point Presentation
mprpgcwa2024
 
Learning Styles Inventory for Senior High School Students
Thelma Villaflores
 
Andreas Schleicher_Teaching Compass_Education 2040.pdf
EduSkills OECD
 
The Power of Compound Interest (Stanford Initiative for Financial Decision-Ma...
Stanford IFDM
 
Elo the HeroTHIS IS A STORY ABOUT A BOY WHO SAVED A LITTLE GOAT .pptx
JoyIPanos
 
How to Add New Item in CogMenu in Odoo 18
Celine George
 
Wikinomics How Mass Collaboration Changes Everything Don Tapscott
wcsqyzf5909
 
Peer Teaching Observations During School Internship
AjayaMohanty7
 
Lesson 1 : Science and the Art of Geography Ecosystem
marvinnbustamante1
 
Our Guide to the July 2025 USPS® Rate Change
Postal Advocate Inc.
 
How to Setup Automatic Reordering Rule in Odoo 18 Inventory
Celine George
 
M&A5 Q1 1 differentiate evolving early Philippine conventional and contempora...
ErlizaRosete
 
SYMPATHOMIMETICS[ADRENERGIC AGONISTS] pptx
saip95568
 
Elo the Hero is an story about a young boy who became hero.
TeacherEmily1
 
THE PSYCHOANALYTIC OF THE BLACK CAT BY EDGAR ALLAN POE (1).pdf
nabilahk908
 
COM and NET Component Services 1st Edition Juval Löwy
kboqcyuw976
 
DIGESTION OF CARBOHYDRATES ,PROTEINS AND LIPIDS
raviralanaresh2
 
CAD25 Gbadago and Fafa Presentation Revised-Aston Business School, UK.pdf
Kweku Zurek
 
Free eBook ~100 Common English Proverbs (ebook) pdf.pdf
OH TEIK BIN
 

Introduction to CSS

  • 1. Introduction to CSS By Amit Tyagi
  • 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.