Skip to Content
Creating a Website: The Missing Manual, 4th Edition
book

Creating a Website: The Missing Manual, 4th Edition

by Matthew MacDonald
June 2015
Beginner
620 pages
18h 6m
English
O'Reilly Media, Inc.
Content preview from Creating a Website: The Missing Manual, 4th Edition

Chapter 3. Building a Style Sheet

Last chapter, you learned HTML’s dirty little secret: It doesn’t have much formatting muscle. As a result, if you want your web pages to look sharp, you need to add style sheets into the page-creation mix.

A style sheet is simply a document filled with formatting rules. Browsers read these rules and apply them when they display web pages. For example, a style sheet rule might say, “Make all the headings on this site bold and fuchsia, and draw a box around each one.”

You want to put formatting instructions in a style sheet instead of embedding them in a web page for several reasons. The most obvious is reusability. Thanks to style sheets, for example, you can create a single rule to, say, format all level-3 headings a certain way. When you apply this rule to your site, it changes the appearance of every level-3 heading on every web page.

The second reason is that style sheets help you write tidy, readable, and manageable HTML files. Because style sheets handle all your site’s formatting, your HTML document doesn’t need to do that work. All it needs to do is organize your pages into logical sections.

Finally, style sheets give you more extensive formatting choices than HTML does. Using style sheets, you can control colors, borders, margins, alignment, and fonts. These formatting features are either out of reach in HTML, or they require some seriously messy markup.

In this chapter, you’ll learn how style sheets work, and how to attach one to a web page. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Creating a Website: The Missing Manual, 3rd Edition

Creating a Website: The Missing Manual, 3rd Edition

Matthew MacDonald
Web Site Cookbook

Web Site Cookbook

Doug Addison

Publisher Resources

ISBN: 9781449374525Errata Page