← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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