← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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