← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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