← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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