← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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