← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 486 · 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.💪 Which flexbox property turns on flexbox? (a) justify-content (b) gap (c) display: flex (d) flex-direction
  2. 2.✍️ What is the selector in this CSS rule?
    h2 {
      text-align: center;
      color: red;
      font-style: italic;
    }
    (a) h1 (b) h2 (c) text-align (d) red
  3. 3.Which of these does HTML do? (a) reacts to a button click (b) shows a pop-up message (c) makes a form box (d) adds space around boxes
  4. 4.What does justify-content: space-between do? (a) packs boxes at the end (b) puts boxes in the middle (c) equal gaps, none at ends (d) packs boxes at the start
  5. 5.True or false: JavaScript checks a quiz answer. (a) True (b) False
  6. 6.⚖️ What colour is the text of this element?
    <h2 class="big" id="logo">Hi</h2>
    CSS:
    #logo { color: orange; }
    #logo { color: green; }
    (a) blue (b) orange (c) red (d) green
  7. 7.📦 In the box model, which part is the gap to other boxes? (a) content (b) margin (c) padding (d) border
  8. 8.💪 Which flexbox property sets space between boxes? (a) align-items (b) gap (c) justify-content (d) display: flex
  9. 9.✍️ CSS declarations go inside which brackets? (a) < > (b) ( ) (c) { } (d) [ ]
  10. 10.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 260px;
      justify-content: flex-start;
    }
    Inside are 4 boxes, each 60px wide (no margins).
  11. 11.✍️ What is the selector in this CSS rule?
    .box {
      margin: 10px;
      font-style: italic;
    }
    (a) h2 (b) .box (c) margin (d) italic
  12. 12.📱 The screen is 375px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 20px;
      }
    }
    (a) Yes (b) No
  13. 13.True or false: CSS rounds box corners. (a) False (b) True
  14. 14.🖌️ What colour is behind the letters?
    h2 {
      text-align: right;
      background-color: yellow;
      font-size: 36px;
      color: red;
    }
    (a) orange (b) red (c) yellow
  15. 15.🧩 Which language puts a picture on a page? (a) HTML (b) JavaScript (c) CSS
  16. 16.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 280px;
      padding: 20px;
      border: 2px solid black;
      margin: 0px;
    }
  17. 17.🖌️ Which CSS property makes the text bold? (a) font-family (b) text-align (c) background-color (d) font-weight
  18. 18.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 230px;
      padding: 30px;
      border: 5px solid black;
      margin: 15px;
    }
  19. 19.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 280px;
      padding: 20px;
      border: 2px solid black;
      margin: 0px;
    }
  20. 20.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 190px;
      justify-content: flex-start;
    }
    Inside are 2 boxes, each 60px wide (no margins).
  21. 21.⚖️ What colour is the text of this element?
    <h2 class="big" id="main">Hi</h2>
    CSS:
    h2 { color: blue; }
    h2 { color: orange; }
    (a) orange (b) blue (c) yellow (d) green
  22. 22.⚖️ What colour is the text of this element?
    <h2 class="menu" id="logo">Hi</h2>
    CSS:
    .menu { color: green; }
    h2 { color: white; }
    #logo { color: blue; }
    (a) blue (b) purple (c) green (d) white
  23. 23.🎯 Which sign starts an id selector? (a) . (b) # (c) & (d) @
  24. 24.✍️ How many declarations (property: value pairs) are in this rule?
    body {
      padding: 8px;
      margin: 10px;
      border: 2px solid;
      color: red;
    }
  25. 25.✍️ How many declarations (property: value pairs) are in this rule?
    h1 {
      margin: 10px;
    }
  26. 26.True or false: img is a class selector. (a) True (b) False
  27. 27.💪 Which justify-content value equal gaps, none at ends? (a) space-between (b) flex-end (c) flex-start (d) center
  28. 28.Which of these is the content? (a) a solid or dotted edge (b) the line round the box (c) space inside the border (d) the text or picture
  29. 29.What does font-family do? (a) colours behind the text (b) picks the font style (c) makes the text bold (d) centres a heading
  30. 30.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 18px;
      }
    }
  31. 31.🌈 In #010000 the red part is the hex number 01. What is it as a normal number?
  32. 32.🌈 Which colour of light is strongest in rgb(200, 126, 42)? (a) red (b) green (c) blue
  33. 33.🖌️ What colour is behind the letters?
    p {
      color: purple;
      text-align: center;
      background-color: yellow;
      font-size: 36px;
    }
    (a) yellow (b) purple (c) blue
  34. 34.🎨 Which attribute adds CSS inside one tag? (a) style (b) href (c) src (d) alt
  35. 35.🌈 Which hex code is blue? (a) #00ffff (b) #0000ff (c) #00ff00 (d) #ffffff
  36. 36.⚖️ What colour is the text of this element?
    <p class="note" id="main">Hi</p>
    CSS:
    p { color: red; }
    #main { color: yellow; }
    (a) blue (b) orange (c) red (d) yellow
  37. 37.⚖️ What colour is the text of this element?
    <p class="box" id="top">Hi</p>
    CSS:
    p { color: orange; }
    p { color: blue; }
    (a) black (b) blue (c) green (d) orange
  38. 38.🖌️ What colour are the letters?
    h1 {
      font-size: 16px;
      text-align: left;
      color: black;
      background-color: red;
    }
    (a) black (b) red (c) blue
  39. 39.📱 min-width: 800px applies when the screen is ___. (a) turned off (b) exactly 100px (c) 800px or wider (d) 800px or narrower
  40. 40.🎯 Which CSS selector matches this element?
    <div class="red" id="top">Hello</div>
    (a) #intro (b) .red (c) .box (d) #red

Answer key

  1. display: flex
  2. h2
  3. makes a form box
  4. equal gaps, none at ends
  5. True
  6. green
  7. margin
  8. gap
  9. { }
  10. 20
  11. .box
  12. No
  13. True
  14. yellow
  15. HTML
  16. 324
  17. font-weight
  18. 300
  19. 324
  20. 70
  21. orange
  22. blue
  23. #
  24. 4
  25. 1
  26. False
  27. space-between
  28. the text or picture
  29. picks the font style
  30. 18
  31. 1
  32. red
  33. yellow
  34. style
  35. #0000ff
  36. yellow
  37. blue
  38. black
  39. 800px or wider
  40. .red

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