← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 1 · 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.✍️ How many declarations (property: value pairs) are in this rule?
    h2 {
      text-align: center;
      width: 300px;
      font-size: 20px;
    }
  2. 2.🎨 What does CSS stand for? (a) Colourful Site Styles (b) Cascading Style Sheets (c) Computer Style Sheets (d) Creative Sheet System
  3. 3.⚖️ What colour is the text of this element?
    <p class="menu" id="main">Hi</p>
    CSS:
    #main { color: blue; }
    #main { color: red; }
    (a) black (b) purple (c) red (d) blue
  4. 4.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 220px;
      justify-content: flex-start;
    }
    Inside are 4 boxes, each 50px wide (no margins).
  5. 5.✍️ What value is given to width in this rule?
    h1 {
      width: 300px;
      background-color: yellow;
      font-size: 20px;
    }
    (a) italic (b) red (c) 300px (d) width
  6. 6.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 340px;
      justify-content: space-between;
    }
    Inside are 4 boxes, each 40px wide (no margins).
  7. 7.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 140px;
      padding: 25px;
      border: 3px solid black;
      margin: 15px;
    }
  8. 8.🎯 Which sign starts a class selector? (a) & (b) # (c) @ (d) .
  9. 9.🖌️ Where does the text sit on its line?
    li {
      text-align: center;
      color: green;
      font-size: 16px;
      background-color: white;
    }
    (a) in the middle (b) on the left (c) on the right
  10. 10.✍️ How many declarations (property: value pairs) are in this rule?
    body {
      background-color: yellow;
      text-align: center;
      margin: 10px;
    }
  11. 11.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 250px;
      justify-content: center;
    }
    Inside are 3 boxes, each 50px wide (no margins).
  12. 12.🖌️ Where does the text sit on its line?
    li {
      background-color: purple;
      font-size: 36px;
      color: white;
      text-align: left;
    }
    (a) on the left (b) in the middle (c) on the right
  13. 13.🌈 Which hex code is magenta? (a) #ff0000 (b) #ffffff (c) #ff00ff (d) #000000
  14. 14.Which of these does JavaScript do? (a) makes a link (b) lays out the page (c) makes headings and lists (d) counts down a timer
  15. 15.🎯 Which sign starts an id selector? (a) . (b) # (c) & (d) @
  16. 16.🌈 Which colour is #ff00ff? (a) red (b) magenta (c) black (d) yellow
  17. 17.🖌️ Which CSS property picks the font style? (a) font-size (b) background-color (c) text-align (d) font-family
  18. 18.True or false: .big is an element selector. (a) False (b) True
  19. 19.✍️ What is the selector in this CSS rule?
    .box {
      padding: 8px;
      border: 2px solid;
      font-style: italic;
    }
    (a) .box (b) padding (c) h2 (d) 2px solid
  20. 20.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 20px;
      }
    }
  21. 21.⚖️ 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
  22. 22.✍️ What is the selector in this CSS rule?
    .note {
      font-weight: bold;
      margin: 10px;
      font-size: 20px;
      text-align: center;
    }
    (a) .note (b) 10px (c) font-weight (d) #top
  23. 23.🌈 In #090000 the red part is the hex number 09. What is it as a normal number?
  24. 24.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 130px;
      padding: 30px;
      border: 3px solid black;
      margin: 10px;
    }
  25. 25.⚖️ What colour is the text of this element?
    <h2 class="big" id="main">Hi</h2>
    CSS:
    h2 { color: blue; }
    .big { color: white; }
    (a) blue (b) purple (c) black (d) white
  26. 26.🎯 Which CSS selector matches this element?
    <span class="star" id="intro">Hello</span>
    (a) #main (b) span (c) .intro (d) p
  27. 27.✍️ Which sign goes between a property and its value? (a) : (b) - (c) ; (d) =
  28. 28.Which of these does JavaScript do? (a) makes a form box (b) makes a link (c) changes the page live (d) makes headings and lists
  29. 29.📱 max-width: 600px applies when the screen is ___. (a) exactly 1000px (b) 600px or wider (c) turned off (d) 600px or narrower
  30. 30.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 50px;
      padding: 10px;
      border: 4px solid black;
      margin: 20px;
    }
  31. 31.📱 The screen is 320px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 10px;
      }
    }
    (a) Yes (b) No
  32. 32.🖌️ Which CSS property colours behind the text? (a) text-align (b) font-size (c) color (d) background-color
  33. 33.⚖️ Which selector is the strongest? (a) an id selector (b) an element selector (c) a class selector
  34. 34.⚖️ What colour is the text of this element?
    <h2 class="red" id="logo">Hi</h2>
    CSS:
    #logo { color: yellow; }
    #logo { color: blue; }
    (a) orange (b) yellow (c) white (d) blue
  35. 35.🧩 Which language reacts to a button click? (a) JavaScript (b) HTML (c) CSS
  36. 36.True or false: padding is the gap round content. (a) False (b) True
  37. 37.💪 Which justify-content value equal gaps, none at ends? (a) center (b) flex-end (c) flex-start (d) space-between
  38. 38.🎯 Which CSS selector matches this element?
    <li class="box" id="top">Hello</li>
    (a) #box (b) .top (c) li (d) #intro
  39. 39.🎯 Which element does the selector h2 style? (a) <span id="top"> (b) <li> (c) <div class="big"> (d) <h2 class="big">
  40. 40.Which of these does HTML do? (a) rounds box corners (b) sets colours and fonts (c) gives the page structure (d) shows a pop-up message

Answer key

  1. 3
  2. Cascading Style Sheets
  3. red
  4. 20
  5. 300px
  6. 60
  7. 196
  8. .
  9. in the middle
  10. 3
  11. 50
  12. on the left
  13. #ff00ff
  14. counts down a timer
  15. #
  16. magenta
  17. font-family
  18. False
  19. .box
  20. 20
  21. the later one
  22. .note
  23. 9
  24. 196
  25. white
  26. span
  27. :
  28. changes the page live
  29. 600px or narrower
  30. 118
  31. Yes
  32. background-color
  33. an id selector
  34. blue
  35. JavaScript
  36. True
  37. space-between
  38. li
  39. <h2 class="big">
  40. gives the page structure

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