← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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