← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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