← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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