SlideShare a Scribd company logo
1 of 11
WEBD 162
Week 5: Introduction to Cascading Style
Sheets (CSS)
CSS Evolution
CSS1: 1996
CSS2.1: 2011
CSS3: in progress
Why CSS?
• Separates web page “appearance” from content for easier
maintenance
• Reusable styles – use to unify pages in a web site
• DRY: Don’t Repeat Yourself
What does Cascading mean?
• Different levels of style sheets can be applied to HTML
• Default Browser style (User Agent)
• Most general: The default if there is no specific style sheet
• Author style
• Web page author creates a style sheet to give HTML a particular look
• Takes precedence over the Default Browser style
• Most common
• User style
• The end user creates their own style sheet to override Author and
Default Browser styles
• One reason might be to accommodate impaired vision (larger font)
• Least common
• See Figure 2-1 Hierarchy of Styles on p.86 of textbook
CSS: Cascading Style Sheets
• CSS is great because it separates style from structure
• Ex: If you wanted to change all h2 tags from red to blue
• Ex: www.csszengarden.com
• 3 ways to apply CSS
• In-line: single instance of a style
• Embedded: style for a single file declared in <head>
• External file: style for one or more files; linked in <head>
Anatomy of a CSS Rule
CSS Rules
• selector
• Which element is going to be affected?
• The rightmost part of selector is the type of element
• Everything to the left specifies which set of elements is affected
• declaration block
• There may be 0 or more declarations between the braces
• declaration
• Property
• Which property of the element gets affected
• Value
• How that property (attribute) gets affected
“Cascading” Style Sheets
• From least important to most important rules/style sheets:
1. User Agent (Browser)
2. User (You) style sheet
3. Author’s rules (Web page designer)
4. Author (Web page designer) !important declarations
5. User (You) !important declarations
• http://www.w3.org/TR/CSS2/cascade.html
• Note: CSS3 is not yet a formal standard
• http://www.sitepoint.com/web-foundations/cascade/
Minimize use of !important
• Using !important makes stylesheets hard to maintain
• Can make it hard to track down rule conflicts
• Useful in user stylesheets to accommodate users with
special needs (e.g. larger fonts for vision impairment)
• http://www.smashingmagazine.com/2010/11/02/the-
important-css-declaration-how-and-when-to-use-it/
• https://css-tricks.com/when-using-important-is-the-
right-choice/
Rule Inheritance
• Simple case:
• If a CSS rule for a selector is not specifically declared in
the web page or associated CSS file
• The CSS rule from the User Agent (browser) is inherited
Last Rule and Fallback Rule
• If a CSS rule appears multiple times on a web page
• Last rule in order of appearance takes effect
• Unless there is a rule with higher specificity
• If last rule cannot be applied, then next to last rule will take effect
• Progressive Enhancement 2.1 p. 104

More Related Content

What's hot

Howcssworks 100207024009-phpapp01
Howcssworks 100207024009-phpapp01Howcssworks 100207024009-phpapp01
Howcssworks 100207024009-phpapp01
Likitha47
 

What's hot (20)

Drupal - Introduction to Drupal Template Design
Drupal - Introduction to Drupal Template DesignDrupal - Introduction to Drupal Template Design
Drupal - Introduction to Drupal Template Design
 
WordPress as a CMS (short version)
WordPress as a CMS (short version)WordPress as a CMS (short version)
WordPress as a CMS (short version)
 
Add Custom Post Types to Your WordPress Website
Add Custom Post Types to Your WordPress WebsiteAdd Custom Post Types to Your WordPress Website
Add Custom Post Types to Your WordPress Website
 
Adobe Dreamweaver CS5 Basics
Adobe Dreamweaver CS5 BasicsAdobe Dreamweaver CS5 Basics
Adobe Dreamweaver CS5 Basics
 
160712 wiki lecture
160712 wiki lecture160712 wiki lecture
160712 wiki lecture
 
CSS Introduction
CSS IntroductionCSS Introduction
CSS Introduction
 
Languages for web(HTML,CSS,JS)
Languages for web(HTML,CSS,JS)Languages for web(HTML,CSS,JS)
Languages for web(HTML,CSS,JS)
 
Introduction to HTML5 and CSS3
Introduction to HTML5 and CSS3Introduction to HTML5 and CSS3
Introduction to HTML5 and CSS3
 
Web
WebWeb
Web
 
CSS Stylesheet Training
CSS Stylesheet TrainingCSS Stylesheet Training
CSS Stylesheet Training
 
UReach drupal-basic-training-2013
UReach drupal-basic-training-2013UReach drupal-basic-training-2013
UReach drupal-basic-training-2013
 
Howcssworks 100207024009-phpapp01
Howcssworks 100207024009-phpapp01Howcssworks 100207024009-phpapp01
Howcssworks 100207024009-phpapp01
 
Drupal: Organizing Content for Multiple Audiences
Drupal: Organizing Content for Multiple AudiencesDrupal: Organizing Content for Multiple Audiences
Drupal: Organizing Content for Multiple Audiences
 
presentation in html,css,javascript
presentation in html,css,javascriptpresentation in html,css,javascript
presentation in html,css,javascript
 
I Blog, You Blog, Weblog
I Blog, You Blog, WeblogI Blog, You Blog, Weblog
I Blog, You Blog, Weblog
 
Evaluating your stylesheets
Evaluating your stylesheetsEvaluating your stylesheets
Evaluating your stylesheets
 
HTML5 for ASP.NET Developers
HTML5 for ASP.NET DevelopersHTML5 for ASP.NET Developers
HTML5 for ASP.NET Developers
 
WordPress block editor v0.0.0
WordPress block editor v0.0.0WordPress block editor v0.0.0
WordPress block editor v0.0.0
 
The 3Cs of WordPress
The 3Cs of WordPressThe 3Cs of WordPress
The 3Cs of WordPress
 
Css intro
Css introCss intro
Css intro
 

Similar to WEBD 162: Intro to CSS

Web design-workflow
Web design-workflowWeb design-workflow
Web design-workflow
Peter Kaizer
 
Web programming css
Web programming cssWeb programming css
Web programming css
Uma mohan
 
howcssworks-100207024009-phpapp01.pptx
howcssworks-100207024009-phpapp01.pptxhowcssworks-100207024009-phpapp01.pptx
howcssworks-100207024009-phpapp01.pptx
RavneetSingh343801
 

Similar to WEBD 162: Intro to CSS (20)

DHTML
DHTMLDHTML
DHTML
 
CSS Bootstrap.pdf
CSS  Bootstrap.pdfCSS  Bootstrap.pdf
CSS Bootstrap.pdf
 
Web design-workflow
Web design-workflowWeb design-workflow
Web design-workflow
 
Unit-3-CSS-BWT.pptx
Unit-3-CSS-BWT.pptxUnit-3-CSS-BWT.pptx
Unit-3-CSS-BWT.pptx
 
CSS.pptx
CSS.pptxCSS.pptx
CSS.pptx
 
DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...
DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...
DRY CSS A don’t-repeat-yourself methodology for creating efficient, unified a...
 
WordCamp NYC - DRY CSS
WordCamp NYC - DRY CSSWordCamp NYC - DRY CSS
WordCamp NYC - DRY CSS
 
INFT132 093 05 Cascading Style Sheets
INFT132 093 05 Cascading Style SheetsINFT132 093 05 Cascading Style Sheets
INFT132 093 05 Cascading Style Sheets
 
Introduction to cascade style sheets CSS.pdf
Introduction to cascade style sheets CSS.pdfIntroduction to cascade style sheets CSS.pdf
Introduction to cascade style sheets CSS.pdf
 
Css
CssCss
Css
 
Cascading style sheets (CSS)
Cascading style sheets (CSS)Cascading style sheets (CSS)
Cascading style sheets (CSS)
 
using cascading style sheets-presentation.ppt
using cascading style sheets-presentation.pptusing cascading style sheets-presentation.ppt
using cascading style sheets-presentation.ppt
 
css-presentation-for mid career engineers.ppt
css-presentation-for mid career engineers.pptcss-presentation-for mid career engineers.ppt
css-presentation-for mid career engineers.ppt
 
Introducing Cascading Style Sheets
Introducing Cascading Style SheetsIntroducing Cascading Style Sheets
Introducing Cascading Style Sheets
 
Stupid Index Block Tricks
Stupid Index Block TricksStupid Index Block Tricks
Stupid Index Block Tricks
 
Dangerous CSS
Dangerous CSSDangerous CSS
Dangerous CSS
 
Std 12 Computer Chapter 2 Cascading Style Sheets and Javascript(Part 1 CSS)
Std 12 Computer Chapter 2 Cascading Style Sheets  and Javascript(Part 1 CSS)Std 12 Computer Chapter 2 Cascading Style Sheets  and Javascript(Part 1 CSS)
Std 12 Computer Chapter 2 Cascading Style Sheets and Javascript(Part 1 CSS)
 
Web programming css
Web programming cssWeb programming css
Web programming css
 
css_1.ppt
css_1.pptcss_1.ppt
css_1.ppt
 
howcssworks-100207024009-phpapp01.pptx
howcssworks-100207024009-phpapp01.pptxhowcssworks-100207024009-phpapp01.pptx
howcssworks-100207024009-phpapp01.pptx
 

Recently uploaded

Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 

Recently uploaded (20)

Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 

WEBD 162: Intro to CSS

  • 1. WEBD 162 Week 5: Introduction to Cascading Style Sheets (CSS)
  • 2. CSS Evolution CSS1: 1996 CSS2.1: 2011 CSS3: in progress
  • 3. Why CSS? • Separates web page “appearance” from content for easier maintenance • Reusable styles – use to unify pages in a web site • DRY: Don’t Repeat Yourself
  • 4. What does Cascading mean? • Different levels of style sheets can be applied to HTML • Default Browser style (User Agent) • Most general: The default if there is no specific style sheet • Author style • Web page author creates a style sheet to give HTML a particular look • Takes precedence over the Default Browser style • Most common • User style • The end user creates their own style sheet to override Author and Default Browser styles • One reason might be to accommodate impaired vision (larger font) • Least common • See Figure 2-1 Hierarchy of Styles on p.86 of textbook
  • 5. CSS: Cascading Style Sheets • CSS is great because it separates style from structure • Ex: If you wanted to change all h2 tags from red to blue • Ex: www.csszengarden.com • 3 ways to apply CSS • In-line: single instance of a style • Embedded: style for a single file declared in <head> • External file: style for one or more files; linked in <head>
  • 6. Anatomy of a CSS Rule
  • 7. CSS Rules • selector • Which element is going to be affected? • The rightmost part of selector is the type of element • Everything to the left specifies which set of elements is affected • declaration block • There may be 0 or more declarations between the braces • declaration • Property • Which property of the element gets affected • Value • How that property (attribute) gets affected
  • 8. “Cascading” Style Sheets • From least important to most important rules/style sheets: 1. User Agent (Browser) 2. User (You) style sheet 3. Author’s rules (Web page designer) 4. Author (Web page designer) !important declarations 5. User (You) !important declarations • http://www.w3.org/TR/CSS2/cascade.html • Note: CSS3 is not yet a formal standard • http://www.sitepoint.com/web-foundations/cascade/
  • 9. Minimize use of !important • Using !important makes stylesheets hard to maintain • Can make it hard to track down rule conflicts • Useful in user stylesheets to accommodate users with special needs (e.g. larger fonts for vision impairment) • http://www.smashingmagazine.com/2010/11/02/the- important-css-declaration-how-and-when-to-use-it/ • https://css-tricks.com/when-using-important-is-the- right-choice/
  • 10. Rule Inheritance • Simple case: • If a CSS rule for a selector is not specifically declared in the web page or associated CSS file • The CSS rule from the User Agent (browser) is inherited
  • 11. Last Rule and Fallback Rule • If a CSS rule appears multiple times on a web page • Last rule in order of appearance takes effect • Unless there is a rule with higher specificity • If last rule cannot be applied, then next to last rule will take effect • Progressive Enhancement 2.1 p. 104