← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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