← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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