← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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