← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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