Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

CHAPTER 5

  1. Why aren't the values of the font-weight property 100 through 900, bolder, and lighter used in real-world web design?

    A. Because commonly available fonts are either bold or they aren't, and since there is only one variation, bold and normal, the other values aren't used.

  2. How could the following rules be better written?
    p {
        font-family: Arial, sans-serif;
        font-weight: bold;
        font-size: 24px;
        color: crimson;
    }
    p.copy {
        font-style: italic;
        font-weight: bold;
        line-height: 2em;
    }
    p#footer {
        font-size: 12px;
        line-height: 2em;
        font-family: Helvetica, Arial, sans-serif;
    }

    A.

    p {
        font: bold 24px Arial, sans-serif;
        color: crimson;
    }
    p.copy {
        font-style: italic;
        font-weight: bold;
        line-height: 2em;
    }
    p#footer {
        font: 12px/2em Helvetica, Arial, sans-serif;
    }

    The second rule, which begins with the selector p.copy, had no change, because there is no font-size and no font-family specified in the rule, which are both required for the font shorthand property. Another acceptable approach would be to repeat the font-size and font-family as defined in the first rule, since it applies to all <p> elements. If you repeated the font-size and font-family from the first rule, another acceptable answer would be:

    p.copy {
        font: italic bold 24px/2em Arial, sans-serif;
    }

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial