Chapter 6 Introducing Cascading Style Sheets Principles of Web Design, Third Edition.

Slides:



Advertisements
Similar presentations
Introduction to HTML & CSS
Advertisements

Intro To Cascading Style Sheets By Mario Yannakakis.
CSS Cascading Style Sheets. Objectives Using Inline Styles Working with Selectors Using Embedded Styles Using an External Style Sheet Applying a Style.
© 2004, Robert K. Moniot Chapter 6 CSS : Cascading Style Sheets.
CSS BASICS. CSS Rules Components of a CSS Rule  Selector: Part of the rule that targets an element to be styled  Declaration: Two or more parts: a.
Recognizing the Benefits of Using CSS 1. The Evolution of CSS CSS was developed to standardize display information CSS was slow to be supported by browsers.
Chapter 8 Creating Style Sheets.
XP Introducing Cascading Style Sheets With Cascading Style Sheets (CSS), you can create one or more documents that control the appearance of some or all.
Chapter 6 Web Typography
Cascading Style Sheets. Slide 2 Lecture Overview Overview of Cascading Style Sheets (CSS) Ways to declare a CSS CSS formatting capabilities New features.
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic CSS: Cascading Style Sheets.
Web Workshop: CSS Objectives: - “What is CSS?” - Structure of CSS - How to use CSS in your webpage.
XP 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
Working with Cascading Style Sheets. 2 Objectives Introducing Cascading Style Sheets Using Inline Styles Using Embedded Styles Using an External Style.
Tutorial 3: Adding and Formatting Text. 2 Objectives Session 3.1 Type text into a page Copy text from a document and paste it into a page Check for spelling.
1 Working with Cascading Style Sheet (CSS). 2 Cascading Style Sheets (CSS)  a style defines the appearance of a document element. o E.g., font size,
Principles of Web Design 6 th Edition Chapter 4 – Cascading Style Sheets.
Chapter 4 Cascading Style Sheets Basics Key Concepts Copyright © 2013 Terry Ann Morris, Ed.D 1.
Chapter 11 Cascading Style Sheets: Part I The Web Warrior Guide to Web Design Technologies.
XP Tutorial 7New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks.
Dreamweaver -- CSS. Dreamweaver -- MX New icons are added in MX Most of the features commonly used in web design, and are same as FrontPage. New feature.
Chapter 7 Web Typography Principles of Web Design, 4 th Edition.
Week 4.  Three ways to apply CSS: Inline CSS Internal style sheets ( header style information) External style sheets.
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.
Cascading Style Sheet (CSS)
Chapter 6 Web Typography. 2 Principles of Web Design Chapter 5 Objectives Understand principles for type design on a Web site Use the element Understand.
Cascading Style Sheets. Defines the presentation of one or more web pages Similar to a template Can control the appearance of an entire web site giving.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 3 Key Concepts 1 Copyright © Terry Felke-Morris.
CIS 1315 – Web Development for Educators CIS 1315 HTML Tutorials 3 & 4: Working With CSS.
Cascading Style Sheets Orientation Learning Web Design: Chapter 11.
Cascading Style Sheets Chapter Four. What are they? A set of style rules that tell the web browser how to present a web page or document. Cascading Style.
CO1552 – Web Application Development Cascading Style Sheets.
IS 360 Declaring CSS Styles. Slide 2 Introduction Learn about the three ways to declare a style Inline / embedded / external Learn about the effect of.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Tutorial 7.
Chapter 6 Introducing Cascading Style Sheets Principles of Web Design, 4 th Edition.
ECA225 Applied Interactive Programming Cascading Style Sheets, pt 1 ECA 225 Applied Online Programming.
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.
XP Review 2 New Perspectives on JavaScript, Comprehensive1 Introducing Cascading Style Sheets Formatting Web Pages with CSS.
1 Working with Cascading Style Sheet (CSS). 2 Cascading Style Sheets (CSS)  a style defines the appearance of a document element. o E.g., font size,
CNIT 132 – Week 4 Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of.
CSS Cascading Style Sheets A very brief introduction CSS, Cascading Style Sheets1.
Microsoft Expression Web 3 – Illustrated Unit D: Structuring and Styling Text.
Relative, absolute, and Floating Positioning, Cascading Style Sheet, and Inheritance.
Basic Webpage Design Cascading Style Sheet (CSS).
ECA 228 Internet/Intranet Design I Cascading Style Sheets.
HTML 5 AND CSS Dr Mohd Soperi Mohd Zahid Semester /16.
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
What is CSS? A set of style rules that tell the web browser how to present a web page or document. – In earlier versions of HTML, style characteristics,
CSS Introductions. Objectives To take control of the appearance of a Web site by creating style sheets. To use a style sheet to give all the pages of.
Internet & World Wide Web How to Program, 5/e 1. 2.
Working with Cascading Style Sheets
Basics of Web Design Chapter 4 Cascading Style Sheets Basics Key Concepts Copyright © 2013 Terry Ann Morris, Ed.D.
CSS: Cascading Style Sheets
>> Introduction to CSS
Madam Hazwani binti Rahmat
>> CSS Rules Selection
Basics of Web Design Chapter 4 Cascading Style Sheets Basics Key Concepts Copyright © 2013 Terry Ann Morris, Ed.D.
Intro to CSS CS 1150 Fall 2016.
Cascading Style Sheets - Building a stylesheet
Intro to CSS CS 1150 Spring 2017.
Basics of Web Design Chapter 4 Cascading Style Sheets Basics Key Concepts Copyright © 2013 Terry Ann Morris, Ed.D.
IS 360 Understanding CSS Selectors
Using Cascading Style Sheets (CSS)
Tutorial 3 Working with Cascading Style Sheets
Chapter 6 Introducing Cascading Style Sheets
Cascading Style Sheets - Building a stylesheet
Presentation transcript:

Chapter 6 Introducing Cascading Style Sheets Principles of Web Design, Third Edition

2 Objectives Understand CSS style rules Build a basic style sheet Understand the cascade Use basic selection techniques Use advanced selection techniques

Principles of Web Design, Third Edition3 Understanding CSS Style Rules Cascading style sheets offer much greater control over type characteristics than does the element You can use standard type conventions, such as using point or pixel sizes, setting leading, and specifying indents and alignment

Principles of Web Design, Third Edition4 Cascading Style Sheet Reference Appendix B of text Dreamweaver reference – resources.htmwww.dreamweaver-templates.org/css- resources.htm Web Tutorials - –CSS Tutorial -

Principles of Web Design, Third Edition5 Understanding CSS Style Rules Style rules are composed of two parts: a selector and a declaration The selector determines the element to which the rule is applied The declaration details the exact property values

Principles of Web Design, Third Edition6

7 Understanding CSS Style Rules h1 {color: red;} The declaration contains a property and a value The property (like color) is a quality or characteristic The precise specification of the property is contained in the value (red) CSS includes over 50 different properties, each with a specific number of values

Principles of Web Design, Third Edition8

9 CSS Basics Combining CSS Rules with XHTML –The element –External style sheet

Principles of Web Design, Third Edition10 CSS Basics Combining CSS Rules with XHTML –External style sheet Text document that contains style rules Allows specification of rules for multiple HTML documents Does not contain HTML code Link command in section

Principles of Web Design, Third Edition11 Combining CSS Rules with XHTML –The element Always contained in the section of the document Generally used to override a style set at a higher level in the document for a single document Only affects the document in which it resides CSS Basics

Principles of Web Design, Third Edition12 Using Descendant Selectors A descendant selector lets you specify the exact context in which a style is applied. To specify that elements appear blue only within elements, use the following rule: h1 {color: blue;}

Principles of Web Design, Third Edition13 Combining CSS Rules with XHTML –The style attribute Defines a style for a single element Generally used to override a style set at a higher level in the document for a single element Only affects one instance of an element in a document CSS Basics

Principles of Web Design, Third Edition14 Grouping Selectors The following rule selects the H1 and H2 elements: h1, h2 {color: green;}

Principles of Web Design, Third Edition15 CSS Basics Combining CSS Rules with XHTML –Linking to an external style sheet element establishes document relationships –Can only be used in the section of a document –Tells the browser where to find the external style sheet

Principles of Web Design, Third Edition16 CSS Basics Combining CSS Rules with XHTML –Combining multiple style keyword –allows import of style rules from other style sheets –must precede all rules in style sheet or they will be ignored by the browser Style rules contained within document take precedence over imported style rules Weight of imported style sheets based on import order

Principles of Web Design, Third Edition17 CSS Basics Understanding the Cascade –Cascading mechanism of CSS determines which rules are assigned to document elements by assigning a weight based on four variables: use of the !important keyword origin of the rule specificity of the selector order of the rule in the style sheet

Principles of Web Design, Third Edition18 CSS Basics Understanding the Cascade –Determining rule weight with the !important keyword Allows user to override author’s style setting for a particular element Improves accessibility of documents –gives control to users with special requirements

Principles of Web Design, Third Edition19 CSS Basics Understanding the Cascade –Determining rule weight by origin Cascading order of precedence: –rules from author’s style sheet –rules from user’s style sheet –rules from Browser’s style sheet

Principles of Web Design, Third Edition20

Principles of Web Design, Third Edition21 CSS Basics Understanding the Cascade –Determining rule weight by specificity Rules with more specific selectors take precedence over rules with less specific selectors –Determining rule weight by order Based on order of rule within style sheet –Those listed later take precedence over those listed earlier in the style sheet

Principles of Web Design, Third Edition22 CSS Basics Understanding Inheritance –Based on hierarchical structure of documents CSS rules inherit from parent elements to child elements: –thus elements will inherit style rules from elements unless a style rule is specifically set for the element

Principles of Web Design, Third Edition23

Principles of Web Design, Third Edition24 Understanding Basic Selection Techniques Using type selectors Grouping selectors Combining declarations Using descendant selectors

Principles of Web Design, Third Edition25 Using Type Selectors The following rule selects the H1 element:

Principles of Web Design, Third Edition26 Combining Declarations The following style rules set the element to 12-point blue text: p {color: blue;} p {font-size: 12pt;} These two style rules can be expressed in a simpler way: p {color: blue; font-size: 12pt;}

Principles of Web Design, Third Edition27 Understanding Advanced Selection Techniques Using the class attribute Using the and elements

Principles of Web Design, Third Edition28 Using the class Attribute Selector The class attribute lets you write rules and then apply them to groups of elements that you have classified To create a class, declare it within the element first. The period (.) flag character indicates that the selector is a class selector.

Principles of Web Design, Third Edition29 Using the class Attribute Selector

Principles of Web Design, Third Edition30 Using the class Attribute Selector. special {font-size: 10pt; font-weight: bold;} This is the first paragraph of the document. It has a different style based on the “special” class selector.

Principles of Web Design, Third Edition31 Working With The element lets you specify logical divisions within a document that have their own name and style properties is a block-level element. It contains a leading and trailing carriage return. You can use with the class attribute to create customized block-level elements

Principles of Web Design, Third Edition32 Working With To create a division, declare it within the element first. The following example specifies a division named introduction as the selector for the rule: div.introduction {color:red;}

Principles of Web Design, Third Edition33 Working With Next, specify the element in the document. Then use the class attribute to specify the exact type of division. In the following example, the code defines the element as the special class named “introduction.” Some text

Principles of Web Design, Third Edition34 Working with The element lets you specify inline elements within a document that have their own name and style properties Inline elements go within the line of text, like the element

Principles of Web Design, Third Edition35 Working with To create a span, declare it within the element first. The following example specifies a element named “logo” as the selector for the rule: span.logo {color:red;}

Principles of Web Design, Third Edition36 Working with Next, specify the element in the document. Then use the class attribute to specify the exact type of span. In the following example, the code defines the element as the special class named “logo.” Welcome to the Wonder Software Web site.

Principles of Web Design, Third Edition37 Working with Welcome to the Wonder Software Web site.

Principles of Web Design, Third Edition38 Summary CSS rules can be combined with your XHTML code in a number of ways. CSS rules are easy to write and read. CSS uses cascading and inheritance to determine which style rules take precedence. The !important declaration lets users override the author’s style rules.

Principles of Web Design, Third Edition39 Summary Basic style rules let you apply style rules based on standard element selectors. –You can combine the selectors and declarations to create more powerful style expressions. –You can also select elements based on the contextual relationship of elements in the document tree.

Principles of Web Design, Third Edition40 Summary The advanced selection techniques allow you to use the class attribute selector, which is often paired with the and XHTML elements. –These elements have no style of their own, but offer a convenient way of expressing style for any section of a document, whether block- level or inline. –Additionally, class allows you to choose a meaningful naming convention for your style rules.

Principles of Web Design, Third Edition41 The End Questions ?