← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 217 · 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.⚖️ What colour is the text of this element?
    <h1 class="red" id="hero">Hi</h1>
    CSS:
    #hero { color: red; }
    .red { color: blue; }
    h1 { color: white; }
    (a) blue (b) orange (c) red (d) white
  2. 2.✍️ What is the selector in this CSS rule?
    p {
      padding: 8px;
      font-weight: bold;
      background-color: yellow;
    }
    (a) p (b) .note (c) bold (d) padding
  3. 3.⚖️ What colour is the text of this element?
    <p class="box" id="main">Hi</p>
    CSS:
    p { color: black; }
    .box { color: blue; }
    (a) orange (b) blue (c) black (d) red
  4. 4.🧩 Which language changes the page live? (a) HTML (b) JavaScript (c) CSS
  5. 5.🎯 Which CSS selector matches this element?
    <p class="box" id="top">Hello</p>
    (a) .top (b) #intro (c) h1 (d) .box
  6. 6.What does justify-content: space-between do? (a) packs boxes at the start (b) puts boxes in the middle (c) packs boxes at the end (d) equal gaps, none at ends
  7. 7.True or false: JavaScript reacts to a button click. (a) True (b) False
  8. 8.True or false: img is an id selector. (a) True (b) False
  9. 9.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 14px;
      }
    }
  10. 10.Which of these is the content? (a) the gap to other boxes (b) the text or picture (c) the line round the box (d) space inside the border
  11. 11.⚖️ What colour is the text of this element?
    <h1 class="big" id="end">Hi</h1>
    CSS:
    h1 { color: blue; }
    h1 { color: red; }
    (a) white (b) blue (c) black (d) red
  12. 12.True or false: .card is an id selector. (a) True (b) False
  13. 13.🌈 Which colour of light is strongest in rgb(228, 70, 128)? (a) blue (b) green (c) red
  14. 14.🖌️ Where does the text sit on its line?
    h1 {
      font-size: 12px;
      color: red;
      background-color: purple;
      text-align: center;
    }
    (a) on the left (b) in the middle (c) on the right
  15. 15.🖌️ Which CSS property picks the font style? (a) text-align (b) font-size (c) font-weight (d) font-family
  16. 16.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 140px;
      justify-content: flex-end;
    }
    Inside are 2 boxes, each 50px wide (no margins).
  17. 17.⚖️ What colour is the text of this element?
    <p class="star" id="hero">Hi</p>
    CSS:
    .star { color: red; }
    .star { color: yellow; }
    (a) red (b) black (c) yellow (d) white
  18. 18.What does justify-content: flex-start 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
  19. 19.🎯 What kind of selector is .menu? (a) a class selector (b) an id selector (c) an element selector
  20. 20.🧩 Which language changes the text size? (a) JavaScript (b) HTML (c) CSS
  21. 21.🌈 Which hex code is blue? (a) #000000 (b) #00ff00 (c) #ff00ff (d) #0000ff
  22. 22.True or false: .big is an id selector. (a) False (b) True
  23. 23.✍️ How does a CSS comment start? (a) // (b) <!-- (c) # (d) /*
  24. 24.✍️ How many declarations (property: value pairs) are in this rule?
    #top {
      font-weight: bold;
      color: red;
    }
  25. 25.📱 max-width: 600px applies when the screen is ___. (a) turned off (b) exactly 1000px (c) 600px or wider (d) 600px or narrower
  26. 26.Which of these does CSS do? (a) adds space around boxes (b) makes a link (c) reacts to a button click (d) gives the page structure
  27. 27.✍️ How many declarations (property: value pairs) are in this rule?
    li {
      font-size: 20px;
      background-color: yellow;
    }
  28. 28.🖌️ Where does the text sit on its line?
    h2 {
      text-align: center;
      background-color: red;
      color: yellow;
      font-size: 36px;
    }
    (a) on the left (b) in the middle (c) on the right
  29. 29.📱 The screen is 320px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 14px;
      }
    }
    (a) No (b) Yes
  30. 30.✍️ CSS declarations go inside which brackets? (a) ( ) (b) < > (c) { } (d) [ ]
  31. 31.🌈 Which colour is rgb(255, 0, 255)? (a) yellow (b) magenta (c) blue (d) red
  32. 32.✍️ In color: blue; which part is the value? (a) color (b) blue (c) ; (d) :
  33. 33.🌈 What is the biggest number one colour can have in rgb()? (a) 99 (b) 255 (c) 1000 (d) 100
  34. 34.🎯 Which sign starts a class selector? (a) @ (b) . (c) & (d) #
  35. 35.⚖️ What colour is the text of this element?
    <p class="note" id="intro">Hi</p>
    CSS:
    .note { color: black; }
    .note { color: blue; }
    (a) blue (b) black (c) yellow (d) purple
  36. 36.💪 Which flexbox property sets space between boxes? (a) gap (b) align-items (c) display: flex (d) justify-content
  37. 37.What does text-align do? (a) colours behind the text (b) picks the font style (c) makes the text bold (d) centres a heading
  38. 38.🌈 Which colour is rgb(255, 0, 0)? (a) magenta (b) red (c) white (d) black
  39. 39.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 160px;
      padding: 30px;
      border: 4px solid black;
      margin: 10px;
    }
  40. 40.✍️ How many declarations (property: value pairs) are in this rule?
    #top {
      font-style: italic;
      font-weight: bold;
      padding: 8px;
      font-size: 20px;
    }

Answer key

  1. red
  2. p
  3. blue
  4. JavaScript
  5. .box
  6. equal gaps, none at ends
  7. True
  8. False
  9. 14
  10. the text or picture
  11. red
  12. False
  13. red
  14. in the middle
  15. font-family
  16. 40
  17. yellow
  18. packs boxes at the start
  19. a class selector
  20. CSS
  21. #0000ff
  22. False
  23. /*
  24. 2
  25. 600px or narrower
  26. adds space around boxes
  27. 2
  28. in the middle
  29. Yes
  30. { }
  31. magenta
  32. blue
  33. 255
  34. .
  35. blue
  36. gap
  37. centres a heading
  38. red
  39. 248
  40. 4

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