← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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