← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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