← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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