← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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