← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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