14.5. Capitalization

The text-transform property can be used to force particular capitalization on elements. This property has four possible values:

  • none (default)

  • capitalize

  • uppercase

  • lowercase

Setting the appropriate value will force the user agent to render the text (if possible) using that setting. For example, you may want all your headings in title case (as in this book, where most words begin with a capital letter). To do so, you could use a style similar to the following:

h1, h2, h3, h4, h5, h6  { text-transform: capitalize; }

This won't quite have the desired effect, as conjunctions (and, or, and so on) and other words not commonly capitalized in initial-caps schemes will still be capitalized.

Get Web Standards Programmer's Reference: HTML, CSS, JavaScript®, Perl, Python®, and PHP 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.