← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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