← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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