← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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