← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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