Classes and Ids:Quiz

1) Which CSS would select an ID named first?

Answer: #first

2) Which CSS selector will select only list items that are direct children of a div?

Answer: div > li

3) Which CSS selector will select any list item within a div?

Answer: div li

4) Which pseudo-class selects text when the mouse is directly over it?

Answer: hover

5) Complete the following sentence: "If HTML were a tree..."

Answer: The trunk is <html> and the first branches are <head> and <title>

6) Why would you use "id" rather than "class"?

Answer: All of these are correct (To select one element for special treatment, To single out an element from others like it, To give an element a unique style)

7) How are the p and div related in this code sample?


<div>

  <p>How are we related?</p>

</div>

Answer: The div is the parent of the p

8) Which of the following CSS selectors will override the other 3?

Answer: div ul li ol p

9) When should you use a class selector?

Answer: To select many elements that should receive the same styling

10) Which CSS would select a class named question?

Answer: .question

results matching ""

    No results matching ""