Chapter 46. Defining Class Styles

You saw in Topic 45 about how to redefine the appearance of HTML tags with great precision. But what happens if you need a style that doesn't necessarily apply to any particular HTML tag or logical sequence of tags? Never fear. CSS, like the Buddha, provides. Simply define your own style selector, called a class.

GEEKSPEAK

A class is a custom-made style selector that doesn't necessarily apply to any particular HTML tag or sequence of tags.

A typical class style rule looks something like this:

.bolditalic {
  font-weight: bold;
  font-style: italic;
}

Come up with a name for your class, and put a period in front of it, as in .bolditalic in the preceding code. Then, just write the style definition. It's as easy ...

Get Web Design Garage 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.