← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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