← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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