Chapter 44. Creating Custom Formatting Styles
For as beloved as HTML's formatting tags are in certain circles of Web design, these tags are pretty limited. They give you only the most basic formatting options: boldface, italic, underline, and strikethrough.
TIPThe formatting tags in HTML include b (boldface), i (italic), u (underline), and s or strike (strikethrough). |
CSS ATTRIBUTE | POSSIBLE VALUES | EXAMPLE |
---|---|---|
font-weight | bold, bolder, lighter, normal | font-weight: bolder; |
font-style | italic, oblique, normal | font-style: oblique; |
font-variant | normal, small-caps | font-variant: small-caps; |
text-decoration | underline, overline, line-through, none | text-decoration: overline; |
text-transform | capitalize, uppercase, lowercase, none | text-transform: capitalize; |
Listing 44.1. View Source for Figure 44.1.
<style type="text/css">
.o {
text-decoration: overline;
}
</style>
<p>
<q>I thought we went <span class="o">over</span> this,</q> said Captain Steward.
</p>
Figure 44.1. Use CSS to create overlines instead of underlines.
[View full size image]
Listing 44.2. View Source for Figure 44.2.
<style type="text/css">
.sc {
font-variant: small-caps;
}
</style>
<p>
<span class="sc">The Buck Stops Here.</span> That's what the placard on his desk said.
</p>
Figure 44.2. Convert lowercase letters in the source code to small caps in the browser.
[View full size image]
Listing 44.3. View Source for Figure 44.3.
<p style="text-transform: capitalize;">an ordinary line of text, so transformed by CSS</p>
<p style="text-transform: uppercase;">an ordinary line of text, so transformed by CSS</p>
<p style="text-transform: lowercase;">an ordinary line of text, so transformed by CSS</p>
Figure 44.3. Change sentence casing with the values of the text-transform attribute.
[View full size image]