← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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