XML technologies / CSS / CSS Cookbook / Design with CSS / Combining seemingly incompatible things to create contrast
(Excerpt from “CSS Kochbuch” by Christopher Schmitt)
Problem
Contrast should be created on a web page by combining two different elements, such as serif and sans-serif fonts (see the following figure).
Figure: Two different typefaces in the same heading.
Solution
Use two different fonts in the same heading. First add the necessary markup to the heading:
<h2>Cross<span>i</span>ng <span>Over</span></h2>
<h4>Sen. Jane Gordon (<span>I</span>-Utah) bolts GOP; <br />changes part<span>i</span>es to be <span>I</span>ndependent</h4>Next, create the CSS rules defining the different fonts in the two span elements:
body {
margin: 25% 10% 0 10%;
}
h2 {
font-size: 2em;
font-weight: bold;
font-family: Arial, Verdana, Helvetica, sans-serif;
text-transform: uppercase;
text-align: center;
padding: 0;
margin: 0;
}
h2 span {
font-family: Times, "Times New Roman", Georgia, serif;
font-size: 1.1em;
font-weight: normal;
}
h4 {
margin: 0;
padding: 0;
font-size: 1.25em;
font-weight: bold;
font-family: Arial, Verdana, Helvetica, sans-serif;
text-transform: uppercase;
text-align: center;
}
h4 span {
font-family: Times, "Times New Roman", Georgia, serif;
font-size: 1.1em;
font-weight: normal;
}Discussion
Combining seemingly unrelated elements can create contrast. Our example uses the different appearance of serif and sans-serif fonts for this purpose. Contrast can also be achieved graphically, for example by combining symbols of two different political parties. Alternatively, use contrast more symbolically, for example by showing two different parties: a large gathering in a club and a girl blowing out the candles on her birthday cake.
See also
The recipe Combining different image formats.
Copyright of the German edition © 2007 by O’Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from “CSS Kochbuch” 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.
O’Reilly Verlag GmbH & Co. KG, Balthasarstr. 81, 50670 Köln