Chapter 9. WORKING WITH OTHER CSS SELECTORS

Apply Styles to More than One Element at a Time

Often, you will have several elements to which you want to apply the same style. Writing separate declarations for these elements is not only needlessly redundant, but it also makes updating the styles difficult. For example, say you wished to apply a text color to paragraphs and first- and second-level headings. It would work to write three separate declarations, setting the color in each, but if you later decided you wanted a different color, you would need to change all three to retain consistency.

To solve this issue, CSS allows you to create declarations that contain multiple selectors. So long as you plan to apply the exact same style rules to each ...

Get HTML, XHTML, and CSS: Your visual blueprint™ for designing effective Web pages 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.