← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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