← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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