← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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