Chapter 6 Introducing Cascading Style Sheets

Slides:



Advertisements
Similar presentations
Table, List, Blocks, Inline Style
Advertisements

Introduction to HTML & CSS
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.
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.
Chapter 6 Web Typography
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic CSS: Cascading Style Sheets.
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.
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 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.
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
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.
CIS 1315 – Web Development for Educators CIS 1315 HTML Tutorials 3 & 4: Working With CSS.
Cascading Style Sheets Orientation Learning Web Design: Chapter 11.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Tutorial 7.
Css. Definition Cascading style sheet (CSS)  It is a simple mechanism for adding style (e.g. fonts, colors, spacing) to Web documents.
Chapter 6 Introducing Cascading Style Sheets Principles of Web Design, 4 th Edition.
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.
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.
Chapter 6 Introducing Cascading Style Sheets Principles of Web Design, Third Edition.
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.
IS 360 Understanding CSS Selectors. Slide 2 Types of Selectors There are different types of selectors Each has a different level of “specificity” An element.
Internet & World Wide Web How to Program, 5/e 1. 2.
Working with Cascading Style Sheets
CSS Cascading Style Sheets
Web Development & Design Foundations with XHTML
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
Introduction to CSS.
Cascading Style Sheets
Cascading Style Sheets
IS 360 Declaring CSS Styles
Madam Hazwani binti Rahmat
>> CSS Rules Selection
Chapter 3 Style Sheets: CSS
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.
Website Design 3
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.
CS134 Web Design & Development
IS 360 Understanding CSS Selectors
Introduction to Cascading Style Sheets (CSS)
Web Programming– UFCFB Lecture 11
Working with Cascading Style Sheets (CSS)
Working with Cascading Style Sheets (CSS)
Cascading Style Sheets
Tutorial 3 Working with Cascading Style Sheets
Introduction to CSS.
Web Design & Development
Cascading Style Sheets
Session 3: Basic CSS Spring 2009
Cascading Style Sheets - Building a stylesheet
CS332A Advanced HTML Programming
Presentation transcript:

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

Understanding CSS Style Rules Cascading style sheets offer much greater control over type characteristics than does the <font> 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 Edition

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 Edition

Principles of Web Design, Third Edition

Understanding CSS Style Rules The declaration contains a property and a value The property is a quality or characteristic The precise specification of the property is contained in the value CSS includes over 50 different properties, each with a specific number of values Principles of Web Design, Third Edition

Principles of Web Design, Third Edition

CSS Basics Combining CSS Rules with XHTML Three ways to combine CSS rules and XHTML The style attribute The <style> element External style sheet Principles of Web Design, Third Edition

CSS Basics 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 Principles of Web Design, Third Edition

CSS Basics Combining CSS Rules with XHTML The <style> element Always contained in the <head> 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 Principles of Web Design, Third Edition

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 Principles of Web Design, Third Edition

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

CSS Basics Combining CSS Rules with XHTML Combining multiple style sheets @import 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 Edition

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 Edition

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 Edition

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 Edition

Principles of Web Design, Third Edition

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 Edition

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

Principles of Web Design, Third Edition

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

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

Grouping Selectors <style type=”text/css”> The following rule selects the H1 and H2 elements: <style type=”text/css”> h1, h2 {color: green;} </style> Principles of Web Design, Third Edition

Combining Declarations The following style rules set the <p> 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 Edition

Using Descendant Selectors A descendant selector lets you specify the exact context in which a style is applied. To specify that <b> elements appear blue only within <p> elements, use the following rule: <style type=”text/css”> p b {color: blue;} </style> Principles of Web Design, Third Edition

Understanding Advanced Selection Techniques Using the class attribute Using the <div> and <span> elements Principles of Web Design, Third Edition

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 <style> element first. The period (.) flag character indicates that the selector is a class selector. Principles of Web Design, Third Edition

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

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

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

Working With <div> To create a division, declare it within the <style> element first. The following example specifies a division named introduction as the selector for the rule: <style type=”text/css”> div {font-size:80;} div.introduction {color:red;} div.debbie{color:grey;} </style> Principles of Web Design, Third Edition

Working With <div> Next, specify the <div> element in the document. Then use the class attribute to specify the exact type of division. In the following example, the code defines the <div> element as the special class named “introduction.” <div class=“introduction”>Some text</div> <div style:!important font-size:12’>…</div> Principles of Web Design, Third Edition

Working with <span> The <span> 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 <b> element Principles of Web Design, Third Edition

Working with <span> To create a span, declare it within the <style> element first. The following example specifies a <span> element named “logo” as the selector for the rule: <style type=”text/css”> span.logo {color:red;} </style> Principles of Web Design, Third Edition

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

Working with <span> Welcome to the <span class=“logo”>Wonder Software</span> Web site. Principles of Web Design, Third Edition