← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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