← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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