← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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