Sams Teach Yourself CSS in 10 Minutes

Styling the <h2> Element

To add a color to the <h2> element, use the color property. The color can be changed to suit your needs.

The font weight, size, and family are set using the font property, and the heading is centered using the text-align property as shown in Listing 9.3 and illustrated in Figure 9.1.

Listing 9.3. CSS Code Setting Text Alignment

h1#header { color: #036; font: bold 100% arial, helvetica, sans-serif; text-align: center; }

Figure 9.1. Screenshot of styled heading.

Категории