← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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