← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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