← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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