SlideShare a Scribd company logo
INFT11/71-132
       Web Applications


Cascading Style Sheets
        Dr Michael Rees
  School of Information Technology

        mrees@bond.edu.au
Semantics and Presentation

• HTML markup represents:
   – Semantics: <h1> means that an element is a top-
     level heading
   – Presentation: <h1> elements look a certain way

• Separate semantics from presentation:
   – Easier to present on multiple platforms (browser,
     cell phone, spoken, …)
   – Easier to generate documents with consistent look
   – Semantic and presentation defined independently
     (division of labor)
   – User control of presentation is facilitated
© 2009 Michael Rees                Web Applications   2
Cascading Style Sheets

• Styles sheets define how HTML elements are to be
  displayed

• Styles are normally saved in external style sheets
  (.css files)

• External style sheets enable you to change the
  appearance and layout of all the pages in your site,
  just by editing one single CSS document!




© 2009 Michael Rees                Web Applications    3
CSS - Introduction

• Cascading style sheets improve page load time for
  your site as there is less data to transfer

• Normally, a browser has to download all of your
  formatting code in each and every one of your pages
  on your site

• With CSS, the style sheet is downloaded once and
  cached, and every page request-response cycle after
  the first page is shorter




© 2009 Michael Rees                 Web Applications   4
Cascading Style Sheets

• CSS is a vendor-neutral standard defined by the W3C
  (World Wide Web Consortium)

• CSS added to HTML 4.0

• CSS is an extension to HTML to give web site
  developers fine control over page content display

• CSS offers much more control over content than
  HTML tags alone

• CSS is supported by all major browsers

• CSS uses common (electronic) publishing terminology
© 2009 Michael Rees                Web Applications   5
CSS Style Sheet Types
• External (Linked) style sheet:
   – Style rules stored in separate .css file
   – A single .css file can be linked to any number of pages
   – A single page can link to many external style sheets
• Embedded (Internal) style sheet:
   – Stored in the <head> tag of the page
   – Enclosed in <style> … </style> tags
   – Affects only that page
   – Overrides external style sheet
• Inline style:
    – Specified in style attribute in individual HTML tags
    – Applies only to that tag
    – Overrides external and embedded style sheets
• All 3 types of style sheets can be cascaded (mixed) in a single page

© 2009 Michael Rees                  Web Applications              6
Cascading Order
• What style will be used when there is more than one
  style specified for an HTML tag?
• All the styles will ‘cascade’ into a new ‘virtual’ style
  sheet in the following priority order:
     1. Inline style (inside an HTML tag)
     2. Embedded style sheet (inside the <head> tag)
     3. External style sheet(s); last sheet linked in page
        takes precedence
     4. Browser default style sheet




© 2009 Michael Rees                Web Applications   7
CSS Notation

• CSS uses simple declarative syntax to specify a
  collection of style rules to control the layout and
  typography a page

       http://www.w3schools.com/css/




© 2009 Michael Rees                  Web Applications   8
Style Rule Syntax
• A CSS style rule is made up
  of two parts:
                                                       Example rule:
   – Selector: the part of                                 H1 { color: red }
      HTML in the page that
      CSS style modifies
   – Declaration: style setting                  Selector
      applied to selector, again                                 Declaration
      in two parts:
        • property name                                H1 { color: red }

        • property value
                                                        Name          Value



© 2009 Michael Rees                 Web Applications                           9
CSS Selectors
• Single element type:



• Multiple element types:



• All element types:



• Specific elements by id:


© 2009 Michael Rees              Web Applications   10
Class Selector
• Elements belonging to a style class:


          – Referencing a style class in HTML:



• Elements of a certain type and class:




© 2009 Michael Rees               Web Applications   11
Link Pseudo-Classes

• a:link {color:#FF0000}           /* unvisited link */

• a:visited {color:#00FF00} /* visited link */

• a:hover {color:#FF00FF} /* mouse over link */

• a:active {color:#0000FF} /* selected link */




© 2009 Michael Rees                Web Applications       12
CSS Colour

  • CSS measures colour in two ways, either by a colour
    name (like ‘blue’) or by numerical RGB specification:
    #99CCFF - hexadecimal for sky blue

  • http://www.w3schools.com/css/css_colors.asp




© 2009 Michael Rees                Web Applications   13
Cascading Style Sheets

• For inspiration, an essential visit:
   – CSS Zen Garden

• Validate your CSS code with:
   – The W3C CSS Validation Service

• Learn the basics of CSS with:
   – W3Schools, CSS Tutorial




© 2009 Michael Rees                Web Applications   14
Resources

• Read Chapter 3 of textbook




© 2009 Michael Rees               Web Applications   15

More Related Content

PPTX
INFT132 093 04 HTML and XHTML
PPTX
Howcssworks 100207024009-phpapp01
PPT
Designing using Web Standards with Dreamweaver
PPTX
PPTX
Cashcading stylesheets
PPTX
css v1 guru
PDF
Html css
INFT132 093 04 HTML and XHTML
Howcssworks 100207024009-phpapp01
Designing using Web Standards with Dreamweaver
Cashcading stylesheets
css v1 guru
Html css

What's hot (20)

PPTX
Css ms megha
PPSX
Steph's Html5 and css presentation
PPTX
Teaching presentation
PPTX
Front End development of biological database
PPTX
Introduction to HTML
PDF
Universal CSS - Betsy Granger - ebookcraft 2018
PPTX
Open source wordpress and drupal
DOCX
2. เมนูของ ms word 2007
PPTX
Prerequisites of Bootstrap
PPT
Working with Mediawiki
PPT
Cascading Style Sheet
PDF
HTML-First at Wiley - Tzviya Siegman & Benjamin Young - ebookcraft 2018
PPTX
Web Development
PPT
Ppt ch10
PPT
Ppt ch11
PPT
Css present
PPTX
Xhtml and html5 basics
Css ms megha
Steph's Html5 and css presentation
Teaching presentation
Front End development of biological database
Introduction to HTML
Universal CSS - Betsy Granger - ebookcraft 2018
Open source wordpress and drupal
2. เมนูของ ms word 2007
Prerequisites of Bootstrap
Working with Mediawiki
Cascading Style Sheet
HTML-First at Wiley - Tzviya Siegman & Benjamin Young - ebookcraft 2018
Web Development
Ppt ch10
Ppt ch11
Css present
Xhtml and html5 basics
Ad

Similar to INFT132 093 05 Cascading Style Sheets (20)

PDF
Introduction to cascade style sheets CSS.pdf
PPT
CSS Overview
PDF
cashcading style sheet note for beginares
PPT
Introduction to css by programmerblog.net
PPTX
uptu web technology unit 2 Css
PPTX
basic programming language AND HTML CSS JAVApdf
PPTX
Cascading Style Sheets (CSS)
PPT
css-presentation.ppt
PPT
Cascading Style Sheets - CSS - Tutorial
PPTX
This is css which compiled by alex that is impo
PPTX
Cascading style sheet, CSS Box model, Table in CSS
PPTX
Beginners css tutorial for web designers
PPTX
BITM3730 9-19.pptx
PPT
PDF
Chapter 3 - CSS.pdf
PPT
New Css style
PPTX
Unit 2 WT-CSS.pptx web technology project
PPTX
Web technology Unit-II Part-C
Introduction to cascade style sheets CSS.pdf
CSS Overview
cashcading style sheet note for beginares
Introduction to css by programmerblog.net
uptu web technology unit 2 Css
basic programming language AND HTML CSS JAVApdf
Cascading Style Sheets (CSS)
css-presentation.ppt
Cascading Style Sheets - CSS - Tutorial
This is css which compiled by alex that is impo
Cascading style sheet, CSS Box model, Table in CSS
Beginners css tutorial for web designers
BITM3730 9-19.pptx
Chapter 3 - CSS.pdf
New Css style
Unit 2 WT-CSS.pptx web technology project
Web technology Unit-II Part-C
Ad

More from Michael Rees (20)

PDF
Activity 25 reflecting on openness
PPTX
Experiences with MOOCs: Challenges and Opportunities
PPTX
MOOCs march on
PPTX
Messing with MOOCs
PDF
Developing Inside the Cloud
PPT
ABC Gold Coast Social Media Talk
PPTX
Virtualisation advances for teaching and research
PPTX
Building Classroom Community
PPTX
Teaching with Social Media
PPTX
Teaching with Social Media
PPTX
Cloud Apps Ascent - Snapshot
PPTX
Cloud Apps Survival Of The Fittest
PPTX
INFT132 093 07 Document Object Model
PPTX
INFT132 093 03 Web Concepts
PPTX
INFT132 093 02 Internet Concepts
PPT
Get Connected - Building a Social Media Roadmap
PPT
Favourite Cloud Apps
PPTX
Screencasting to Enhance Teaching Materials
PPTX
QCEC2009 Virtual IT Teaching Laboratory
PPT
Screencasting At Bond
Activity 25 reflecting on openness
Experiences with MOOCs: Challenges and Opportunities
MOOCs march on
Messing with MOOCs
Developing Inside the Cloud
ABC Gold Coast Social Media Talk
Virtualisation advances for teaching and research
Building Classroom Community
Teaching with Social Media
Teaching with Social Media
Cloud Apps Ascent - Snapshot
Cloud Apps Survival Of The Fittest
INFT132 093 07 Document Object Model
INFT132 093 03 Web Concepts
INFT132 093 02 Internet Concepts
Get Connected - Building a Social Media Roadmap
Favourite Cloud Apps
Screencasting to Enhance Teaching Materials
QCEC2009 Virtual IT Teaching Laboratory
Screencasting At Bond

Recently uploaded (20)

PDF
Indian roads congress 037 - 2012 Flexible pavement
PDF
Weekly quiz Compilation Jan -July 25.pdf
PDF
Hazard Identification & Risk Assessment .pdf
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PPTX
A powerpoint presentation on the Revised K-10 Science Shaping Paper
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
What if we spent less time fighting change, and more time building what’s rig...
PDF
Complications of Minimal Access Surgery at WLH
PDF
IGGE1 Understanding the Self1234567891011
PPTX
Radiologic_Anatomy_of_the_Brachial_plexus [final].pptx
PDF
Classroom Observation Tools for Teachers
PDF
SOIL: Factor, Horizon, Process, Classification, Degradation, Conservation
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
Practical Manual AGRO-233 Principles and Practices of Natural Farming
PPTX
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
PPTX
Unit 4 Skeletal System.ppt.pptxopresentatiom
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
Indian roads congress 037 - 2012 Flexible pavement
Weekly quiz Compilation Jan -July 25.pdf
Hazard Identification & Risk Assessment .pdf
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Orientation - ARALprogram of Deped to the Parents.pptx
A powerpoint presentation on the Revised K-10 Science Shaping Paper
Supply Chain Operations Speaking Notes -ICLT Program
Final Presentation General Medicine 03-08-2024.pptx
What if we spent less time fighting change, and more time building what’s rig...
Complications of Minimal Access Surgery at WLH
IGGE1 Understanding the Self1234567891011
Radiologic_Anatomy_of_the_Brachial_plexus [final].pptx
Classroom Observation Tools for Teachers
SOIL: Factor, Horizon, Process, Classification, Degradation, Conservation
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
Practical Manual AGRO-233 Principles and Practices of Natural Farming
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
Unit 4 Skeletal System.ppt.pptxopresentatiom
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Paper A Mock Exam 9_ Attempt review.pdf.

INFT132 093 05 Cascading Style Sheets

  • 1. INFT11/71-132 Web Applications Cascading Style Sheets Dr Michael Rees School of Information Technology mrees@bond.edu.au
  • 2. Semantics and Presentation • HTML markup represents: – Semantics: <h1> means that an element is a top- level heading – Presentation: <h1> elements look a certain way • Separate semantics from presentation: – Easier to present on multiple platforms (browser, cell phone, spoken, …) – Easier to generate documents with consistent look – Semantic and presentation defined independently (division of labor) – User control of presentation is facilitated © 2009 Michael Rees Web Applications 2
  • 3. Cascading Style Sheets • Styles sheets define how HTML elements are to be displayed • Styles are normally saved in external style sheets (.css files) • External style sheets enable you to change the appearance and layout of all the pages in your site, just by editing one single CSS document! © 2009 Michael Rees Web Applications 3
  • 4. CSS - Introduction • Cascading style sheets improve page load time for your site as there is less data to transfer • Normally, a browser has to download all of your formatting code in each and every one of your pages on your site • With CSS, the style sheet is downloaded once and cached, and every page request-response cycle after the first page is shorter © 2009 Michael Rees Web Applications 4
  • 5. Cascading Style Sheets • CSS is a vendor-neutral standard defined by the W3C (World Wide Web Consortium) • CSS added to HTML 4.0 • CSS is an extension to HTML to give web site developers fine control over page content display • CSS offers much more control over content than HTML tags alone • CSS is supported by all major browsers • CSS uses common (electronic) publishing terminology © 2009 Michael Rees Web Applications 5
  • 6. CSS Style Sheet Types • External (Linked) style sheet: – Style rules stored in separate .css file – A single .css file can be linked to any number of pages – A single page can link to many external style sheets • Embedded (Internal) style sheet: – Stored in the <head> tag of the page – Enclosed in <style> … </style> tags – Affects only that page – Overrides external style sheet • Inline style: – Specified in style attribute in individual HTML tags – Applies only to that tag – Overrides external and embedded style sheets • All 3 types of style sheets can be cascaded (mixed) in a single page © 2009 Michael Rees Web Applications 6
  • 7. Cascading Order • What style will be used when there is more than one style specified for an HTML tag? • All the styles will ‘cascade’ into a new ‘virtual’ style sheet in the following priority order: 1. Inline style (inside an HTML tag) 2. Embedded style sheet (inside the <head> tag) 3. External style sheet(s); last sheet linked in page takes precedence 4. Browser default style sheet © 2009 Michael Rees Web Applications 7
  • 8. CSS Notation • CSS uses simple declarative syntax to specify a collection of style rules to control the layout and typography a page http://www.w3schools.com/css/ © 2009 Michael Rees Web Applications 8
  • 9. Style Rule Syntax • A CSS style rule is made up of two parts: Example rule: – Selector: the part of H1 { color: red } HTML in the page that CSS style modifies – Declaration: style setting Selector applied to selector, again Declaration in two parts: • property name H1 { color: red } • property value Name Value © 2009 Michael Rees Web Applications 9
  • 10. CSS Selectors • Single element type: • Multiple element types: • All element types: • Specific elements by id: © 2009 Michael Rees Web Applications 10
  • 11. Class Selector • Elements belonging to a style class: – Referencing a style class in HTML: • Elements of a certain type and class: © 2009 Michael Rees Web Applications 11
  • 12. Link Pseudo-Classes • a:link {color:#FF0000} /* unvisited link */ • a:visited {color:#00FF00} /* visited link */ • a:hover {color:#FF00FF} /* mouse over link */ • a:active {color:#0000FF} /* selected link */ © 2009 Michael Rees Web Applications 12
  • 13. CSS Colour • CSS measures colour in two ways, either by a colour name (like ‘blue’) or by numerical RGB specification: #99CCFF - hexadecimal for sky blue • http://www.w3schools.com/css/css_colors.asp © 2009 Michael Rees Web Applications 13
  • 14. Cascading Style Sheets • For inspiration, an essential visit: – CSS Zen Garden • Validate your CSS code with: – The W3C CSS Validation Service • Learn the basics of CSS with: – W3Schools, CSS Tutorial © 2009 Michael Rees Web Applications 14
  • 15. Resources • Read Chapter 3 of textbook © 2009 Michael Rees Web Applications 15