XML technologies / CSS / Advanced websites with CSS / Behind the scenes / Selectors and the structure of CSS rules / Selector grouping
(Excerpt from “CSS − Advanced websites with Cascading Stylesheets” by Rachel Andrew & Dan Shafer)
Selectors can also be grouped to create a single style rule for several elements in an HTML document. Simply separate the elements with commas.
Consider the following example:
h1, h2, h3 {
font-family: Helvetica, Arial, sans-serif;
color: green;
}The elements in the selector need not belong to the same selector type or have the same level of detail. The following rule assigns all second-level headings (h2) and paragraphs the class spezial:
h2, p.spezial {
font-size: 22px;
}The space after the comma in the selector is optional and may be omitted.
Copyright © 2006 of the German translation, dpunkt.verlag GmbH
You may print the online version for your private use.
Otherwise, this chapter from “CSS − Anspruchsvolle Websites mit Cascading Stylesheets” is subject to the same conditions as the bound edition: the work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
dpunkt.verlag GmbH, Ringstraße 19, 69115 Heidelberg
back to top