← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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