← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 449 · 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.🖌️ Where does the text sit on its line?
    p {
      color: yellow;
      text-align: center;
      background-color: green;
      font-size: 20px;
    }
    (a) on the right (b) in the middle (c) on the left
  2. 2.🌈 Which colour is #00ff00? (a) red (b) bright green (c) magenta (d) blue
  3. 3.True or false: .menu is an id selector. (a) True (b) False
  4. 4.What does font-family do? (a) colours behind the text (b) picks the font style (c) centres a heading (d) makes letters bigger
  5. 5.True or false: JavaScript adds space around boxes. (a) False (b) True
  6. 6.🎯 What kind of selector is h1? (a) an element selector (b) a class selector (c) an id selector
  7. 7.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 240px;
      justify-content: flex-end;
    }
    Inside are 2 boxes, each 80px wide (no margins).
  8. 8.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 140px;
      justify-content: space-between;
    }
    Inside are 2 boxes, each 40px wide (no margins).
  9. 9.✍️ How many declarations (property: value pairs) are in this rule?
    .note {
      width: 300px;
      background-color: yellow;
      border: 2px solid;
      padding: 8px;
    }
  10. 10.🎯 Which CSS selector matches this element?
    <p class="menu" id="hero">Hello</p>
    (a) #menu (b) h1 (c) .hero (d) p
  11. 11.True or false: margin is the text or picture. (a) True (b) False
  12. 12.🧩 Which language makes a link? (a) JavaScript (b) CSS (c) HTML
  13. 13.🌈 Which colour is #ffffff? (a) blue (b) magenta (c) red (d) white
  14. 14.⚖️ What colour is the text of this element?
    <p class="big" id="intro">Hi</p>
    CSS:
    .big { color: red; }
    #intro { color: black; }
    p { color: yellow; }
    (a) yellow (b) purple (c) black (d) red
  15. 15.🔍 Which is the odd one out? (a) gives the page structure (b) adds space around boxes (c) changes the text size (d) sets colours and fonts
  16. 16.💪 Which justify-content value packs boxes at the end? (a) center (b) flex-start (c) space-between (d) flex-end
  17. 17.📱 The screen is 414px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 32px;
      }
    }
    (a) Yes (b) No
  18. 18.✍️ What is the selector in this CSS rule?
    .box {
      font-weight: bold;
      font-size: 20px;
    }
    (a) font-weight (b) h2 (c) 20px (d) .box
  19. 19.⚖️ Which selector is the strongest? (a) a class selector (b) an id selector (c) an element selector
  20. 20.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 60px;
      padding: 15px;
      border: 1px solid black;
      margin: 5px;
    }
  21. 21.💪 Which flexbox property sets space between boxes? (a) display: flex (b) gap (c) flex-direction (d) justify-content
  22. 22.✍️ Which sign ends each CSS declaration? (a) : (b) . (c) ; (d) ,
  23. 23.✍️ What is the selector in this CSS rule?
    body {
      text-align: center;
      margin: 10px;
      font-style: italic;
      background-color: yellow;
    }
    (a) .box (b) body (c) text-align (d) 10px
  24. 24.⚖️ What colour is the text of this element?
    <p class="red" id="top">Hi</p>
    CSS:
    .red { color: black; }
    #top { color: white; }
    (a) black (b) green (c) white (d) blue
  25. 25.⚖️ Which selector is the weakest? (a) a class selector (b) an element selector (c) an id selector
  26. 26.📱 The screen is 414px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 20px;
      }
    }
    (a) Yes (b) No
  27. 27.✍️ Which sign goes between a property and its value? (a) ; (b) = (c) : (d) -
  28. 28.🖌️ Which CSS property sets the letter colour? (a) background-color (b) color (c) font-weight (d) font-size
  29. 29.What does background-color do? (a) centres a heading (b) sets the letter colour (c) colours behind the text (d) picks the font style
  30. 30.🎨 Which tag connects an outside CSS file? (a) <a> (b) <img> (c) <css> (d) <link>
  31. 31.🎨 Which tag holds CSS inside the head? (a) <body> (b) <script> (c) <css> (d) <style>
  32. 32.🎨 What does CSS stand for? (a) Computer Style Sheets (b) Colourful Site Styles (c) Creative Sheet System (d) Cascading Style Sheets
  33. 33.🖌️ What colour is behind the letters?
    h2 {
      color: red;
      font-size: 24px;
      text-align: center;
      background-color: yellow;
    }
    (a) blue (b) red (c) yellow
  34. 34.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 10px;
      }
    }
  35. 35.🎯 Which CSS selector matches this element?
    <p class="red" id="logo">Hello</p>
    (a) .box (b) p (c) h1 (d) .logo
  36. 36.🖌️ Where does the text sit on its line?
    h2 {
      text-align: left;
      color: purple;
      background-color: blue;
      font-size: 40px;
    }
    (a) in the middle (b) on the left (c) on the right
  37. 37.🌈 Which colour of light is strongest in rgb(46, 156, 16)? (a) red (b) green (c) blue
  38. 38.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 340px;
      justify-content: flex-end;
    }
    Inside are 4 boxes, each 80px wide (no margins).
  39. 39.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) neither (c) the shorter one (d) the later one
  40. 40.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 260px;
      justify-content: center;
    }
    Inside are 3 boxes, each 80px wide (no margins).

Answer key

  1. in the middle
  2. bright green
  3. False
  4. picks the font style
  5. False
  6. an element selector
  7. 80
  8. 60
  9. 4
  10. p
  11. False
  12. HTML
  13. white
  14. black
  15. gives the page structure
  16. flex-end
  17. No
  18. .box
  19. an id selector
  20. 102
  21. gap
  22. ;
  23. body
  24. white
  25. an element selector
  26. No
  27. :
  28. color
  29. colours behind the text
  30. <link>
  31. <style>
  32. Cascading Style Sheets
  33. yellow
  34. 10
  35. p
  36. on the left
  37. green
  38. 20
  39. the later one
  40. 10

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