← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

HTML and CSS lesson 17: Which CSS rule wins? · Set 951 · 40 questions
TalentJR

Code tip (Stronger first, then later): Strength: #id > .class > element. The stronger selector wins, wherever it is written. Equal strength: the later rule wins.

NameDateTime takenScore ___ / 40
  1. 1.⚖️ Which selector is the strongest? (a) an element selector (b) an id selector (c) a class selector
  2. 2.⚖️ What colour is the text of this element?
    <p class="box" id="main">Hi</p>
    CSS:
    #main { color: black; }
    #main { color: orange; }
    (a) white (b) orange (c) blue (d) black
  3. 3.⚖️ What colour is the text of this element?
    <h1 class="menu" id="intro">Hi</h1>
    CSS:
    #intro { color: blue; }
    #intro { color: red; }
    (a) purple (b) red (c) blue (d) orange
  4. 4.⚖️ What colour is the text of this element?
    <h1 class="note" id="hero">Hi</h1>
    CSS:
    h1 { color: yellow; }
    h1 { color: green; }
    (a) yellow (b) orange (c) green (d) purple
  5. 5.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) the first one (c) neither (d) the later one
  6. 6.⚖️ What colour is the text of this element?
    <p class="note" id="logo">Hi</p>
    CSS:
    p { color: red; }
    p { color: white; }
    (a) blue (b) red (c) white (d) purple
  7. 7.⚖️ What colour is the text of this element?
    <p class="big" id="hero">Hi</p>
    CSS:
    p { color: yellow; }
    .big { color: orange; }
    (a) yellow (b) green (c) white (d) orange
  8. 8.⚖️ What colour is the text of this element?
    <p class="menu" id="end">Hi</p>
    CSS:
    p { color: green; }
    p { color: red; }
    (a) blue (b) red (c) green (d) purple
  9. 9.⚖️ What colour is the text of this element?
    <h1 class="note" id="main">Hi</h1>
    CSS:
    h1 { color: blue; }
    h1 { color: orange; }
    (a) orange (b) blue (c) red (d) purple
  10. 10.⚖️ What colour is the text of this element?
    <p class="red" id="intro">Hi</p>
    CSS:
    p { color: blue; }
    p { color: black; }
    (a) yellow (b) black (c) blue (d) orange
  11. 11.⚖️ What colour is the text of this element?
    <h2 class="big" id="intro">Hi</h2>
    CSS:
    #intro { color: purple; }
    .big { color: orange; }
    h2 { color: green; }
    (a) green (b) purple (c) orange (d) red
  12. 12.⚖️ What colour is the text of this element?
    <h2 class="star" id="top">Hi</h2>
    CSS:
    #top { color: black; }
    .star { color: yellow; }
    h2 { color: purple; }
    (a) black (b) purple (c) orange (d) yellow
  13. 13.⚖️ What colour is the text of this element?
    <h2 class="note" id="hero">Hi</h2>
    CSS:
    .note { color: black; }
    .note { color: red; }
    (a) red (b) yellow (c) black (d) purple
  14. 14.⚖️ What colour is the text of this element?
    <p class="note" id="intro">Hi</p>
    CSS:
    #intro { color: purple; }
    .note { color: red; }
    p { color: black; }
    (a) black (b) red (c) purple (d) blue
  15. 15.⚖️ What colour is the text of this element?
    <h2 class="red" id="end">Hi</h2>
    CSS:
    #end { color: red; }
    h2 { color: black; }
    (a) black (b) white (c) red (d) orange
  16. 16.⚖️ What colour is the text of this element?
    <p class="red" id="top">Hi</p>
    CSS:
    p { color: black; }
    p { color: orange; }
    (a) orange (b) black (c) white (d) green
  17. 17.⚖️ What colour is the text of this element?
    <h1 class="red" id="logo">Hi</h1>
    CSS:
    h1 { color: white; }
    h1 { color: red; }
    (a) blue (b) white (c) red (d) yellow
  18. 18.⚖️ What colour is the text of this element?
    <h2 class="big" id="main">Hi</h2>
    CSS:
    h2 { color: red; }
    .big { color: orange; }
    (a) orange (b) black (c) yellow (d) red
  19. 19.⚖️ What colour is the text of this element?
    <p class="red" id="top">Hi</p>
    CSS:
    .red { color: white; }
    .red { color: yellow; }
    (a) red (b) yellow (c) white (d) black
  20. 20.⚖️ What colour is the text of this element?
    <h2 class="red" id="intro">Hi</h2>
    CSS:
    .red { color: blue; }
    h2 { color: white; }
    (a) white (b) black (c) red (d) blue
  21. 21.⚖️ Which selector is the weakest? (a) a class selector (b) an element selector (c) an id selector
  22. 22.⚖️ What colour is the text of this element?
    <h1 class="note" id="top">Hi</h1>
    CSS:
    .note { color: purple; }
    .note { color: orange; }
    (a) green (b) black (c) purple (d) orange
  23. 23.⚖️ What colour is the text of this element?
    <h2 class="red" id="hero">Hi</h2>
    CSS:
    .red { color: red; }
    h2 { color: black; }
    #hero { color: green; }
    (a) green (b) red (c) orange (d) black
  24. 24.⚖️ What colour is the text of this element?
    <p class="menu" id="logo">Hi</p>
    CSS:
    p { color: purple; }
    p { color: white; }
    (a) white (b) yellow (c) purple (d) red
  25. 25.⚖️ What colour is the text of this element?
    <h1 class="red" id="top">Hi</h1>
    CSS:
    #top { color: orange; }
    #top { color: purple; }
    (a) white (b) orange (c) red (d) purple
  26. 26.⚖️ What colour is the text of this element?
    <p class="note" id="end">Hi</p>
    CSS:
    p { color: yellow; }
    p { color: blue; }
    (a) green (b) black (c) blue (d) yellow
  27. 27.⚖️ What colour is the text of this element?
    <h1 class="star" id="logo">Hi</h1>
    CSS:
    h1 { color: purple; }
    #logo { color: yellow; }
    .star { color: red; }
    (a) purple (b) orange (c) yellow (d) red
  28. 28.⚖️ What colour is the text of this element?
    <h2 class="note" id="intro">Hi</h2>
    CSS:
    #intro { color: white; }
    #intro { color: orange; }
    (a) orange (b) white (c) blue (d) green
  29. 29.⚖️ What colour is the text of this element?
    <h2 class="star" id="main">Hi</h2>
    CSS:
    h2 { color: red; }
    #main { color: yellow; }
    (a) black (b) red (c) yellow (d) purple
  30. 30.⚖️ What colour is the text of this element?
    <h2 class="red" id="main">Hi</h2>
    CSS:
    #main { color: blue; }
    .red { color: white; }
    (a) red (b) white (c) black (d) blue
  31. 31.⚖️ What colour is the text of this element?
    <h1 class="note" id="main">Hi</h1>
    CSS:
    #main { color: green; }
    .note { color: black; }
    (a) green (b) black (c) yellow (d) blue
  32. 32.⚖️ What colour is the text of this element?
    <h1 class="star" id="intro">Hi</h1>
    CSS:
    h1 { color: orange; }
    .star { color: blue; }
    #intro { color: white; }
    (a) orange (b) red (c) blue (d) white
  33. 33.⚖️ What colour is the text of this element?
    <p class="red" id="top">Hi</p>
    CSS:
    p { color: black; }
    #top { color: white; }
    .red { color: purple; }
    (a) white (b) purple (c) blue (d) black
  34. 34.⚖️ What colour is the text of this element?
    <h2 class="star" id="logo">Hi</h2>
    CSS:
    h2 { color: black; }
    h2 { color: white; }
    (a) purple (b) orange (c) white (d) black
  35. 35.⚖️ What colour is the text of this element?
    <h2 class="big" id="hero">Hi</h2>
    CSS:
    .big { color: blue; }
    h2 { color: black; }
    #hero { color: green; }
    (a) black (b) green (c) white (d) blue
  36. 36.⚖️ What colour is the text of this element?
    <h2 class="note" id="top">Hi</h2>
    CSS:
    h2 { color: purple; }
    h2 { color: black; }
    (a) black (b) green (c) purple (d) white
  37. 37.⚖️ What colour is the text of this element?
    <p class="menu" id="intro">Hi</p>
    CSS:
    p { color: red; }
    p { color: orange; }
    (a) green (b) blue (c) red (d) orange
  38. 38.⚖️ What colour is the text of this element?
    <h2 class="star" id="top">Hi</h2>
    CSS:
    .star { color: red; }
    .star { color: green; }
    (a) green (b) black (c) red (d) white
  39. 39.⚖️ What colour is the text of this element?
    <h2 class="note" id="top">Hi</h2>
    CSS:
    h2 { color: red; }
    .note { color: orange; }
    #top { color: white; }
    (a) orange (b) yellow (c) red (d) white
  40. 40.⚖️ What colour is the text of this element?
    <h1 class="note" id="top">Hi</h1>
    CSS:
    h1 { color: orange; }
    h1 { color: green; }
    (a) orange (b) black (c) green (d) red

Answer key

  1. an id selector
  2. orange
  3. red
  4. green
  5. the later one
  6. white
  7. orange
  8. red
  9. orange
  10. black
  11. purple
  12. black
  13. red
  14. purple
  15. red
  16. orange
  17. red
  18. orange
  19. yellow
  20. blue
  21. an element selector
  22. orange
  23. green
  24. white
  25. purple
  26. blue
  27. yellow
  28. orange
  29. yellow
  30. blue
  31. green
  32. white
  33. white
  34. white
  35. green
  36. black
  37. orange
  38. green
  39. white
  40. green

Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids