Cascading Style Sheets™ (CSS)
Cascading Style Sheets™ (CSS)
5
Cascading Style
Sheets™ (CSS)
OBJECTIVES
In this chapter you will learn:
To control the appearance of a website by
creating style sheets.
To use a style sheet to give all the pages of a
website the same look and feel.
To use the class attribute to apply styles.
To specify the precise font, size, color and other
properties of displayed text.
To specify element backgrounds and colors.
To understand the box model and how to control
margins, borders and padding.
To use style sheets to separate presentation from
content.
2008 Pearson Education, Inc. All rights reserved.
3
5.1 Introduction
5.2 Inline Styles
5.3 Embedded Style Sheets
5.4 Conflicting Styles
5.5 Linking External Style Sheets
5.6 Positioning Elements
5.7 Backgrounds
5.8 Element Dimensions
5.9 Box Model and Text Flow
5.10 Media Types
5.11 Building a CSS Drop-Down Menu
5.12 User Style Sheets
5.13 CSS 3
5.14 Wrap-Up
5.15 Web Resources
2008 Pearson Education, Inc. All rights reserved.
4
5.1 Introduction
• Cascading Style Sheets (CSS)
– Used to specify the presentation of elements separately
from the structure of the document
• CSS validator
jigsaw.w3.org/css-validator/
• link element
– Uses rel attribute to specify a relationship between two
documents
– rel attribute declares the linked document to be a
stylesheet for the document
• type attribute specifies the MIME type of the
related document
• href attribute provides the URL for the
document containing the style sheet
5.7 Backgrounds
• CSS can control the backgrounds of block-level
elements by adding:
– Colors
– Images
• :hover pseudoclass
– used to apply styles to an element when the mouse cursor is
over it
• display property
– allows a programmer to decide if an element is displayed as
a block element, inline element, or is not rendered at all
(none)
5.13 CSS 3
• While CSS 2 is the current W3C
Recommendation, CSS 3 is in development, and
some browsers are beginning to implement some
of the new features that will be in the CSS 3
specification
• CSS 3 will introduce new features related to
borders, backgrounds, text effects, layout, and
more