← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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