Training Guide: Programming in HTML5 with JavaScript and CSS3 Ebook

(Nora) #1

137


Chapter 4 Getting started with CSS3


CHAPTER 4 Getting started with CSS3


Y


ou’ve learned that HTML provides the structure, and JavaScript provides the behavior to
your HTML document. In this chapter, you learn how Cascading Style Sheets (CSS) pro-
vide the presentation to your HTML document. CSS provides the tool to design and create a
great-looking web or Windows 8 application with reusability across all pages.
CSS offers far more choices for rendering a document than are available if you just use
HTML to provide formatting, and CSS is compact and fast. CSS also simplifies site updates,
so you can modify the styles to change the look completely of all HTML documents in your
web or Windows 8 application.
This chapter introduces CSS history briefly and then discusses CSS selectors and proper-
ties in depth.

Lessons in this chapter:
■■Lesson 1: Introducing CSS3 137
■■Lesson 2: Understanding selectors, specificity, and cascading 145
■■Lesson 3: Working with CSS properties 165

Before you begin


To complete this chapter, you must have some understanding of web development. This
chapter requires the hardware and software listed in the “System requirements” section in
the book’s Introduction.

Lesson 1: Introducing CSS3


The principle of Cascading Style Sheets (CSS) has roots in Standardized Generalized Markup
Language (SGML) from the 1980s. Its goals are to create a consistent look across many web-
pages and to separate structure from presentation so you can provide different style sheets
for printing, browsing, or other scenarios.
The World Wide Web Consortium (W3C) published CSS Level 1 recommendations in
December 1996, and then started working on CSS Level 2. (The word recommendation
means a formal release of the publication.) In May 1998, CSS Level 2 was published, and
Free download pdf