← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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