← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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