← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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