← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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