← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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