CSCI N241: Fundamentals of Web Design Copyright ©2006  Department of Computer & Information Science Understanding the Cascade in CSS.

Slides:



Advertisements
Similar presentations
Introduction to HTML & CSS
Advertisements

CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
Cascading Style Sheets
Cascading Style Sheets: Basics I450 Technology Seminar Copyright 2003, Matt Hottell.
Cascading Style Sheets
HTML Overview - Cascading Style Sheets (CSS). Before We Begin Make a copy of one of your HTML file you have previously created Make a copy of one of your.
Making Things Look Nice: Visual Appearance and CSS CMPT 281.
Project 8 Creating Style Sheets.
CHAPTER 8 ADVANCED CSS. LEARNING OBJECTIVES Assign formatting styles to a CSS class definition Use a tag’s class attribute to apply the styles defined.
Creating Special Effects with CSS
CSCI N241: Fundamentals of Web Design Copyright ©2006  Department of Computer & Information Science Using CSS for Float Layouts.
Chapter 7 Using Advanced Cascading Style Sheets HTML5 & CSS 7 th Edition.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 3 Style Sheets: CSS WEB.
XP 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
Tutorial 4 Creating Special Effects with CSS
4.01 Cascading Style Sheets
Pre-Module CSS BTM 395: Internet Programming. Cascading Style Sheets (CSS) Separation of structure from presentation CSS guide and tutorial –
Principles of Web Design 6 th Edition Chapter 4 – Cascading Style Sheets.
Cascading Style Sheets (CSS) Instructor: Mr. Ahmed Al Astal ITGD4104 Department Requirement for senior student University of Palestine Faculty of IT.
Tutorial 4 Creating Special Effects with CSS. XP Objectives Work with CSS selectors Create styles for lists Create and apply class styles Create a rollover.
CSCI N241: Fundamentals of Web Design Copyright ©2006  Department of Computer & Information Science Using the Box Model, & Elements.
Using Styles and Style Sheets for Design
Cascading Style Sheets CSS.  Standard defined by the W3C  CSS1 (released 1996) 50 properties  CSS2 (released 1998) 150 properties (positioning)  CSS3.
INTRODUCTION TO HTML5 CSS Styles. Understanding Style Sheets  HTML5 enables you to define many different types of content on a web page, including headings,
Today’s objectives  Presentational | Inline | Block | Validate  CSS | Rules | Declarations.
Styling and theming Build campaigns in style. What we'll look at... How a web document is structured How HTML and CSS fit together Tools you will need.
ITCS373: Internet Technology Week 3: Introduction to CSS Dr. Faisal Al-Qaed.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
Working with Cascading Style Sheets (CSS) Module 2: HTML Basics LESSON 5.
CSCI N241: Fundamentals of Web Design Copyright ©2006  Department of Computer & Information Science Creating Web Forms.
© 2011 Delmar, Cengage Learning Chapter 8 Using Styles and Design Style Sheets for Design.
CS134 Web Design & Development Cascading Style Sheets (CSS) Mehmud Abliz.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Tutorial 7.
Professor Waterman Cascading Style Sheets (CSS) is a language that works with HTML documents to define the way content is presented. The presentation.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
Cascading Style Sheets CSS.  Standard defined by the W3C  CSS1 (released 1996) 50 properties  CSS2 (released 1998) 150 properties (positioning)  CSS3.
LEARN THE QUICK AND EASY WAY! VISUAL QUICKSTART GUIDE HTML and CSS 8th Edition Chapter 8: Working with Style Sheets.
Cascading Style Sheets CSS. Source W3Schools
XHTML Formatting font with a style declaration. Formatting Font HTML uses the font tag to change size and family of font But… the font tag is being deprecated.
Positioning and Printing Creating Special Effects with CSS.
CSS Cascading Style Sheets A very brief introduction CSS, Cascading Style Sheets1.
Tutorial 4 Creating Special Effects with CSS. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Work with CSS selectors.
Tutorial 4 Creating Special Effects with CSS. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Work with CSS selectors.
Microsoft Expression Web 3 – Illustrated Unit D: Structuring and Styling Text.
Tutorial 4 Creating Special Effects with CSS. XP Objectives Work with CSS selectors Create styles for lists Create and apply class styles Create a rollover.
Cascading Style Sheets Class 3, Lecture 4 Rachel A Ober
CSS: Cascading Style Sheets Part II. Style Syntax.
IN THE DOCUMENT OBJECT MODEL, EACH LINE OF HTML IS AN ELEMENT (AN OBJECT), ABLE TO HAVE ATTRIBUTES, PROPERTIES AND VALUES. CSS TELLS THE BROWSER HOW TO.
1 Lecture 7 Style Sheets: CSS. 2 Motivation HTML markup can be used to represent –Semantics: h1 means that an element is a top-level heading –Presentation:
- WE’LL LOOK AT THE POSITION PROPERTY AND HOW CSS RESOLVES CONFLICTS BETWEEN STYLING INSTRUCTIONS The position property; CSS specificity hierarchy.
Department of Computer Science, Florida State University CGS 3066: Web Programming and Design Spring
Tables creating a table within a web page. What makes up a table? Columns Rows.
NASRULLAHIBA.  It is time to take your web designing skills to the next level with Cascading Style Sheets (CSS). They are a way to control the look and.
Chapter 6 Introducing Cascading Style Sheets Principles of Web Design, Third Edition.
The usable Media types are: all Suitable for all devices Braille Intended for Braille tactile feedback devices. embossed Intended for paged Braille printers.
1 Cascading Style Sheet (CSS). 2 Cascading Style Sheets (CSS)  a style defines the appearance of a document element. o E.g., font size, font color etc…
CSCI N241: Fundamentals of Web Design Copyright ©2006  Department of Computer & Information Science Using CSS for Absolute Layouts.
CASCADING STYLE SHEET CSS. CSS stands for Cascading Style Sheets Styles define how to display HTML elements Styles were added to HTML 4.0 to solve a problem.
WEB FOUNDATIONS CSS Overview. Outline  What is CSS  What does it do  Where are styles stored  Why use them  What is the cascade effect  CSS Syntax.
4.01 Cascading Style Sheets
Cascading Style Sheets
>> CSS Rules Selection
Website Design 3
Intro to CSS Mr. Singh.
Web Design and Development
Tutorial 4 Creating Special Effects with CSS
Chapter 6 Introducing Cascading Style Sheets
Web Design & Development
Cascading Style Sheets
4.01 Cascading Style Sheets
Presentation transcript:

CSCI N241: Fundamentals of Web Design Copyright ©2006  Department of Computer & Information Science Understanding the Cascade in CSS

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science Goals By the end of this unit, you should understand … … how to use multiple style sheets in your web pages.… how to use multiple style sheets in your web pages. … how to use different style sheets for different web agents, including mobile browsers, aural browsers and print media.… how to use different style sheets for different web agents, including mobile browsers, aural browsers and print media. … how to calculate the specificity of a rule.… how to calculate the specificity of a rule. … how to determine precedence.… how to determine precedence.

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science Using Multiple Style Sheets At times, we might need to build a site that uses multiple style sheets (think of corporate, division and store styles).At times, we might need to build a site that uses multiple style sheets (think of corporate, division and store styles). We can use multiple style sheets by adding each in its own separate tag.We can use multiple style sheets by adding each in its own separate tag. What happens if there is a conflict? The web browser gives precedence to the style sheet nearest the bottom (top-to-bottom precedence).What happens if there is a conflict? The web browser gives precedence to the style sheet nearest the bottom (top-to-bottom precedence).

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science Using Multiple Style Sheets Overrides Overrides

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science The media Attribute We can also use multiple style sheets for different type of media.We can also use multiple style sheets for different type of media. For instance, you can specify a style sheet for a traditional web browser, a second sheet for a handheld web browser and a third for printing.For instance, you can specify a style sheet for a traditional web browser, a second sheet for a handheld web browser and a third for printing. We add the media attribute to the tag to indicate the intended media.We add the media attribute to the tag to indicate the intended media.

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science The media Attribute Example: Example: Possible values for media include screen, print, handheld, aural, Braille, projection, tty & tv.Possible values for media include screen, print, handheld, aural, Braille, projection, tty & tv.

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science Cracking the Cascade The Cascade in Cascading Style Sheets refers to how a browser selects which CSS rule it should apply.The Cascade in Cascading Style Sheets refers to how a browser selects which CSS rule it should apply. Actually, there are three groups of style sheets the browser considers:Actually, there are three groups of style sheets the browser considers: –The default browser settings (Lowest Priority) –The user-customized settings –The rules defined by a web page's author (Highest Priority)

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science Determining Precedence A web browser determines precedence for a rule using the following path:A web browser determines precedence for a rule using the following path: 1.Group all style sheets (author, user, default browser) together. 2.Find all declarations that match. 3.Sort all matches in their respective groups: author, user, default browser. 4.Calculate specificity. 5.Sort any conflicting styles based on where they appear in their respective style sheet.

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science Calculating Specificity To calculate specificity, start with three zeroes, like this: 0 0 0To calculate specificity, start with three zeroes, like this: Look at your declaration and decide "Does the selector have any ids?" If it does, add one point to the left-most zero for each id: 0 0 0

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science Calculating Specificity 2.Next, decide "Does the selector have any classes or pseudo-classes?" If it does, add one point to the middle zero for each class/pseudo-class: Finally, determine if the selector has any element names. Add one point to the right-most zero for each element: 0 0 0

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science Let's Try Some! h1.greenteaol li pspan.cd p imga:linkem #elixirs h1.green #sidebar from Head First HTML with CSS & XHTML

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science Determining Precedence Example Let's say that you had the following in your web page: Blueberry Bliss Elixir Let's say that you had the following in your web page: Blueberry Bliss Elixir How would the browser determine precedence?How would the browser determine precedence? - from Head First HTML with CSS & XHTML

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science 1.Gather all Style Sheets AUTHOR'S STYLE SHEET: h1 { color: #EFEFEF; } h1.blueberry { color: blue; } USER'S STYLE SHEET: body h1 { color: #CCCCCC; } BROWSER'S STYLE SHEET: h1 { color: black; }

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science 2.Find All Matching Declarations body h1 { color: #CCCCCC; } h1 { color: black; } h1 { color: #EFEFEF; } h1.blueberry { color: blue; } USER: BROWSER: AUTHOR:

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science 3.Sort Matches by Author, User, Browser h1 { color: #EFEFEF; } h1.blueberry { color: blue; } body h1 { color: #CCCCCC; } h1 { color: black; } AUTHOR USER BROWSER

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science 4.Within Each Group, Sort Matches by Specificity h1.blueberry { color: blue; } h1 { color: #EFEFEF; } body h1 { color: #CCCCCC; } h1 { color: black; } AUTHOR USER BROWSER

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science 5.Sort Conflicts by Where the Rules Appear in their Style Sheets h1.blueberry { color: blue; } h1 { color: #EFEFEF; } body h1 { color: #CCCCCC; } h1 { color: black; } AUTHOR USER BROWSER We can stop here because we don't have any conflicts. The h1.blueberry will apply.

N241: Fundamentals of Web Development Copyright ©2006  Department of Computer & Information Science Questions?

References Freeman, Elisabeth and Eric Freeman. Head First HTML with CSS & XHTML. Sebastopol, CA: 2006.Freeman, Elisabeth and Eric Freeman. Head First HTML with CSS & XHTML. Sebastopol, CA: Neiderst-Robbins, Jennifer. Web Design in a Nutshell, Third Edition. Sebastopol, CA: 2006.Neiderst-Robbins, Jennifer. Web Design in a Nutshell, Third Edition. Sebastopol, CA: 2006.