← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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