O'Reilly logo

HTML, XHTML, and CSS Bible, Fourth Edition by Steven M. Schafer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 27. CSS Values and Units

IN THIS CHAPTER

  • General property value rules

  • Property value metrics

CSS is a rich language offering property-based control over many aspects of your HTML documents. Because the many aspects of the document differ from one another, several different types of metrics must be available — scales of units, such as inches, picas, and such — to be able to adequately apply values to their properties. This chapter covers the various types of metrics available in CSS and some reasoning for where and why to use each.

Note

This chapter summarizes the syntax of values in CSS definitions and the various metric values available in CSS. For specific uses of each metric with each property, see the specific coverage of the individual properties in Chapters 29 through 37.

General Property Value Rules

A style definition's property/value section is contained within the braces of the definition. For example, in the following definition, border-width: 3pt is the property/value clause:

p.bordered  { border-width: 3pt; }

In this clause, the property (border-width) and value (3pt) are separated by a colon and the clause is terminated by a semicolon.

Tip

Technically speaking, the last (or only) property/value clause in a style definition does not need a closing semicolon. However, it is generally good practice to include a semicolon at the end of every property/value clause.

The property half of the clause is fairly straightforward; it is a CSS property keyword. The property/value-separating ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required