← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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