← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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