← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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