← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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