← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 606 · 40 questions
TalentJR

Code tip (Rule, then maths): Find the topic: syntax, selectors, properties, colours, box model, cascade, flexbox or media queries. Decide which rule or property applies to the element. For sizes, write the sum down: both sides for the box model, free space for flexbox.

NameDateTime takenScore ___ / 40
  1. 1.🌈 In #00000e the blue part is the hex number 0e. What is it as a normal number?
  2. 2.🎨 Which attribute adds CSS inside one tag? (a) href (b) style (c) alt (d) src
  3. 3.🌈 Which colour is rgb(255, 255, 255)? (a) white (b) red (c) black (d) magenta
  4. 4.✍️ What is the selector in this CSS rule?
    h2 {
      text-align: center;
      padding: 8px;
    }
    (a) text-align (b) 8px (c) h1 (d) h2
  5. 5.✍️ How many declarations (property: value pairs) are in this rule?
    h1 {
      font-style: italic;
      width: 300px;
      text-align: center;
    }
  6. 6.What does text-align do? (a) makes letters bigger (b) colours behind the text (c) sets the letter colour (d) centres a heading
  7. 7.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 160px;
      padding: 30px;
      border: 4px solid black;
      margin: 15px;
    }
  8. 8.⚖️ Which selector is the strongest? (a) a class selector (b) an element selector (c) an id selector
  9. 9.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 230px;
      padding: 20px;
      border: 5px solid black;
      margin: 20px;
    }
  10. 10.🎯 Which element does the selector #logo style? (a) <span id="end"> (b) <span class="logo"> (c) <span id="logo"> (d) <p class="note">
  11. 11.🧩 Which language adds space around boxes? (a) CSS (b) JavaScript (c) HTML
  12. 12.🖌️ Where does the text sit on its line?
    li {
      color: blue;
      font-size: 32px;
      text-align: left;
      background-color: orange;
    }
    (a) in the middle (b) on the left (c) on the right
  13. 13.🖌️ How big is the text, in px?
    p {
      background-color: blue;
      font-size: 20px;
      text-align: left;
      color: white;
    }
  14. 14.Which of these does HTML do? (a) changes the text size (b) adds space around boxes (c) puts a picture on a page (d) reacts to a button click
  15. 15.✍️ Which property is set to 300px in this rule?
    h1 {
      font-size: 20px;
      color: red;
      border: 2px solid;
      width: 300px;
    }
    (a) 300px (b) font-style (c) color (d) width
  16. 16.⚖️ What colour is the text of this element?
    <p class="red" id="logo">Hi</p>
    CSS:
    .red { color: purple; }
    #logo { color: yellow; }
    (a) black (b) yellow (c) purple (d) orange
  17. 17.💪 Which flexbox property lines boxes up across? (a) align-items (b) justify-content (c) flex-direction (d) gap
  18. 18.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 400px;
      justify-content: center;
    }
    Inside are 3 boxes, each 80px wide (no margins).
  19. 19.⚖️ What colour is the text of this element?
    <h2 class="red" id="intro">Hi</h2>
    CSS:
    .red { color: green; }
    .red { color: purple; }
    (a) orange (b) purple (c) green (d) blue
  20. 20.🧩 Which language shows a pop-up message? (a) HTML (b) CSS (c) JavaScript
  21. 21.✍️ What value is given to width in this rule?
    body {
      background-color: yellow;
      width: 300px;
      font-size: 20px;
    }
    (a) italic (b) width (c) red (d) 300px
  22. 22.🎯 Which CSS selector matches this element?
    <p class="box" id="end">Hello</p>
    (a) #box (b) .end (c) #hero (d) .box
  23. 23.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 210px;
      justify-content: flex-start;
    }
    Inside are 2 boxes, each 80px wide (no margins).
  24. 24.✍️ How many declarations (property: value pairs) are in this rule?
    .box {
      background-color: yellow;
      text-align: center;
    }
  25. 25.What does justify-content: space-between do? (a) puts boxes in the middle (b) packs boxes at the start (c) equal gaps, none at ends (d) packs boxes at the end
  26. 26.📱 Which tag helps phones show a page at the right size? (a) the title tag (b) the hr tag (c) the br tag (d) the viewport meta tag
  27. 27.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 450px;
      justify-content: flex-start;
    }
    Inside are 4 boxes, each 100px wide (no margins).
  28. 28.What does justify-content: center do? (a) packs boxes at the start (b) packs boxes at the end (c) equal gaps, none at ends (d) puts boxes in the middle
  29. 29.✍️ What is the selector in this CSS rule?
    .box {
      color: red;
      background-color: yellow;
      width: 300px;
    }
    (a) h2 (b) color (c) .box (d) yellow
  30. 30.✍️ Which property is set to 20px in this rule?
    .note {
      font-size: 20px;
      margin: 10px;
      background-color: yellow;
      width: 300px;
    }
    (a) text-align (b) 20px (c) font-size (d) background-color
  31. 31.🎯 Which CSS selector matches this element?
    <h2 class="menu" id="intro">Hello</h2>
    (a) .note (b) li (c) .menu (d) .intro
  32. 32.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 270px;
      padding: 20px;
      border: 5px solid black;
      margin: 20px;
    }
  33. 33.✍️ Which property is set to italic in this rule?
    .box {
      width: 300px;
      font-style: italic;
      padding: 8px;
    }
    (a) italic (b) color (c) font-size (d) font-style
  34. 34.⚖️ What colour is the text of this element?
    <h2 class="box" id="main">Hi</h2>
    CSS:
    #main { color: purple; }
    #main { color: yellow; }
    (a) yellow (b) purple (c) white (d) blue
  35. 35.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 190px;
      padding: 10px;
      border: 2px solid black;
      margin: 0px;
    }
  36. 36.⚖️ What colour is the text of this element?
    <h1 class="box" id="top">Hi</h1>
    CSS:
    #top { color: black; }
    #top { color: purple; }
    (a) green (b) black (c) yellow (d) purple
  37. 37.🔍 Which is the odd one out? (a) adds space around boxes (b) changes the page live (c) checks a quiz answer (d) shows a pop-up message
  38. 38.💪 Which justify-content value packs boxes at the start? (a) center (b) space-between (c) flex-start (d) flex-end
  39. 39.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 200px;
      justify-content: center;
    }
    Inside are 2 boxes, each 60px wide (no margins).
  40. 40.🧩 Which language makes a link? (a) JavaScript (b) CSS (c) HTML

Answer key

  1. 14
  2. style
  3. white
  4. h2
  5. 3
  6. centres a heading
  7. 258
  8. an id selector
  9. 320
  10. <span id="logo">
  11. CSS
  12. on the left
  13. 20
  14. puts a picture on a page
  15. width
  16. yellow
  17. align-items
  18. 80
  19. purple
  20. JavaScript
  21. 300px
  22. .box
  23. 50
  24. 2
  25. equal gaps, none at ends
  26. the viewport meta tag
  27. 50
  28. puts boxes in the middle
  29. .box
  30. font-size
  31. .menu
  32. 320
  33. font-style
  34. yellow
  35. 214
  36. purple
  37. adds space around boxes
  38. flex-start
  39. 40
  40. HTML

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