← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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