Training Guide: Programming in HTML5 with JavaScript and CSS3 Ebook

(Nora) #1

Lesson 2: Understanding selectors, specificity, and cascading CHAPTER 4 145


■■The declaration block contains the formatting instructions (declarations).
■■Styles can be inline, embedded, or external.
■■To maintain separation between structure and presentation, use external style sheets.
■■Use the media attribute of the <link> element to specify the target device for a
style sheet.

Lesson review


Answer the following questions to test your knowledge of the information in this lesson. You
can find the answers to these questions and explanations of why each answer choice is correct
or incorrect in the “Answers” section at the end of this chapter.


  1. You want to add a comment to your style sheet that says “temporary.” Which is the
    proper line to add to the CSS file?
    A. //temporary
    B. --temporary
    C. / temporary /
    D. rem temporary

  2. You want to maintain separation between structure and presentation. How do you
    create your style rules?
    A. Use inline styles.
    B. Use embedded styles.
    C. Use external style sheets.
    D. In the HTML document, specify @import to load style sheets.

  3. You want your printer.css style sheet to target printers. How would you set up the style
    sheet link?
    A.
    B.
    C.
    D.


Lesson 2: Understanding selectors, specificity, and cascading


This lesson covers the most important parts of CSS, starting with selectors, which connect
the style rule to your HTML. This lesson then discusses some of the ways you can end up with
multiple style rules for the same HTML and how to determine which selector is most specific.
Finally, this lesson discusses the meaning and value of cascading.
Free download pdf