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 ...

Get HTML, XHTML, and CSS Bible, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.