This brings up an interesting feature of (X)HTML and CSS: You can
combine classes.
Using Brett's example, with a class of .noprint appearing only within the @media tags with a display: none value, you can add a class="noprint" to any element you don't want to display on a printed page.
You can't click on page navigation on a piece of paper, so many people elect to turn printing for navigation off. Somewhere on your page, you probably are declaring a division with an ID of "nav" or "menu" or whatever. Simply adding "class=noprint" at that place on your page will turn off printing that area. But what if you aren't using an ID, but are instead using a class? You can combine classes!
- Code: Select all
<div class="footerstuff noprint">
This works and even validates! The W3C spec says the class attribute assigns
one or more class names to an element. The effect is cumulative. If you had a class, .classOne, that changes your font color to Red, and another class, .classTwo, that makes it oblique,
- Code: Select all
<p class="classOne classTwo">This text would be Red and Oblique</p>
Try it. It's pretty handy.