• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 2. Racehorse Style: CSS Power Po... > Double Team ’em with CSS Classes

Double Team ’em with CSS Classes

Looking for a way to trim some fat from your CSS pages? Take advantage of the modern browser’s capability to render multiple classes. Suppose you’ve got three types of headings in your document: 1) red colored, 2) right justified, and 3) red, right justified. At first glance, you’d think you’d have to declare a CSS selector for each heading, right? Not so, my fellow geek! You only have to create two—one for the color and one for the alignment. The third one can be created by using the other two styles together.

For example, let’s call our initial styles .redHead and .rightHead. To make a given <h1> tag both red and right justified, we’d use code like this:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint