Training Guide: Programming in HTML5 with JavaScript and CSS3 Ebook

(Nora) #1

Answers CHAPTER 4 203


B. Incorrect: The first part of the selector locates the element with id of readingPane
while the second part of the selector returns the first letter of the <div> element,
but not for each paragraph.
C. Incorrect: The first part of the selector locates the element with id of readingPane
while the second part of the selector locates all paragraph elements and returns
only the first paragraph. The style is applied to the entire paragraph.
D. Incorrect: The first part of the selector locates the element with id of readingPane
while the second part of the selector returns the child of its parent, so the style is
applied to the entire <div> element.


  1. Correct answer: A
    A. Correct: Specificity is the deciding factor in this example. The specificity value is
    0,1,2 in the first style rule. The specificity value is 0,0,2 in the second style rule. The
    first value is higher; thus, yellow is displayed.
    B. Incorrect: Remember that textual order comes into play only when the specificity
    values are the same.
    C. Incorrect: There are selector matches that would keep the color from being
    transparent.
    D. Incorrect: There are selector matches that would keep the color from being white.

  2. Correct answer: B
    A. Incorrect: Remember that if the specificity values are the same, textual order dic-
    tates the outcome.
    B. Correct: The specificity value for both style rules is 0,1,2, so textual order dictates
    the outcome. The Department.css file is linked after the Corporate.css file, so the
    style rule in the Department.css file will be applied.
    C. Incorrect: There are selector matches that would keep the color from being
    transparent.
    D. Incorrect: There are selector matches that would keep the color from being white.


Lesson 3



  1. Correct answer: C
    A. Incorrect: The rgb function requires you to specify varying amounts of red, green,
    and blue for each color, so it’s not easy to derive three colors that match.
    B. Incorrect: The rgba function is the same as the rgb function, except that you need
    to specify the alpha (opacity) value, too.
    C. Correct: By using the hsl function, you can set the hue value and then adjust the
    saturation and lightening values to derive other matching colors.
    D. Incorrect: There is no color function that can be used in a style sheet to generate
    a color.

Free download pdf