← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 26 · 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 value is given to background-color in this rule?
    h2 {
      font-weight: bold;
      color: red;
      background-color: yellow;
    }
    (a) background-color (b) 8px (c) yellow (d) 10px
  2. 2.Which of these does HTML do? (a) rounds box corners (b) reacts to a button click (c) counts down a timer (d) makes a link
  3. 3.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 260px;
      justify-content: flex-end;
    }
    Inside are 2 boxes, each 100px wide (no margins).
  4. 4.🎯 Which CSS selector matches this element?
    <h1 class="red" id="main">Hello</h1>
    (a) h2 (b) .red (c) .main (d) #logo
  5. 5.What does font-weight do? (a) makes the text bold (b) makes letters bigger (c) colours behind the text (d) centres a heading
  6. 6.True or false: #top is an element selector. (a) False (b) True
  7. 7.🎯 What kind of selector is #logo? (a) a class selector (b) an id selector (c) an element selector
  8. 8.⚖️ What colour is the text of this element?
    <h1 class="note" id="logo">Hi</h1>
    CSS:
    #logo { color: orange; }
    .note { color: black; }
    h1 { color: red; }
    (a) orange (b) purple (c) red (d) black
  9. 9.📦 In the box model, which part is space outside the border? (a) padding (b) margin (c) border (d) content
  10. 10.🎯 What kind of selector is #end? (a) an element selector (b) a class selector (c) an id selector
  11. 11.🖌️ Where does the text sit on its line?
    li {
      text-align: right;
      font-size: 12px;
      background-color: yellow;
      color: blue;
    }
    (a) on the right (b) on the left (c) in the middle
  12. 12.⚖️ What colour is the text of this element?
    <h2 class="big" id="main">Hi</h2>
    CSS:
    #main { color: blue; }
    #main { color: purple; }
    (a) green (b) blue (c) red (d) purple
  13. 13.⚖️ What colour is the text of this element?
    <p class="star" id="top">Hi</p>
    CSS:
    .star { color: orange; }
    .star { color: red; }
    (a) purple (b) blue (c) orange (d) red
  14. 14.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 200px;
      justify-content: center;
    }
    Inside are 2 boxes, each 50px wide (no margins).
  15. 15.🧩 Which language changes the text size? (a) JavaScript (b) HTML (c) CSS
  16. 16.🎯 Which CSS selector matches this element?
    <span class="red" id="top">Hello</span>
    (a) .box (b) p (c) #top (d) .top
  17. 17.⚖️ What colour is the text of this element?
    <h2 class="box" id="intro">Hi</h2>
    CSS:
    #intro { color: green; }
    #intro { color: red; }
    (a) blue (b) white (c) green (d) red
  18. 18.🧩 Which language rounds box corners? (a) CSS (b) JavaScript (c) HTML
  19. 19.🧩 Which language sets colours and fonts? (a) JavaScript (b) CSS (c) HTML
  20. 20.📦 In the box model, which part is the text or picture? (a) padding (b) border (c) margin (d) content
  21. 21.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 440px;
      justify-content: space-between;
    }
    Inside are 4 boxes, each 50px wide (no margins).
  22. 22.🌈 Which hex code is blue? (a) #00ffff (b) #ffff00 (c) #0000ff (d) #000000
  23. 23.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) neither (c) the first one (d) the later one
  24. 24.📱 Responsive design means a page ___. (a) is only for laptops (b) never changes (c) fits every screen (d) has no pictures
  25. 25.🌈 Which colour is #00ff00? (a) bright green (b) cyan (c) yellow (d) white
  26. 26.What does justify-content: flex-start do? (a) equal gaps, none at ends (b) puts boxes in the middle (c) packs boxes at the start (d) packs boxes at the end
  27. 27.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 20px;
      }
    }
  28. 28.Which of these is margin? (a) the text or picture (b) the line round the box (c) space outside the border (d) space inside the border
  29. 29.🎯 Which element does the selector .star style? (a) <h2 class="star"> (b) <h2 class="menu"> (c) <h2 id="star"> (d) <li class="note">
  30. 30.What does background-color do? (a) makes the text bold (b) sets the letter colour (c) centres a heading (d) colours behind the text
  31. 31.✍️ CSS declarations go inside which brackets? (a) ( ) (b) { } (c) [ ] (d) < >
  32. 32.Which of these does HTML do? (a) shows a pop-up message (b) makes headings and lists (c) rounds box corners (d) changes the page live
  33. 33.Which of these does CSS do? (a) makes headings and lists (b) counts down a timer (c) sets colours and fonts (d) shows a pop-up message
  34. 34.🎯 Which CSS selector matches this element?
    <p class="note" id="intro">Hello</p>
    (a) #intro (b) .intro (c) #main (d) h1
  35. 35.True or false: JavaScript makes a link. (a) False (b) True
  36. 36.🖌️ Which CSS property picks the font style? (a) text-align (b) background-color (c) font-family (d) color
  37. 37.What does text-align do? (a) centres a heading (b) sets the letter colour (c) makes letters bigger (d) makes the text bold
  38. 38.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 26px;
      }
    }
  39. 39.📱 The screen is 1100px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 14px;
      }
    }
    (a) No (b) Yes
  40. 40.📱 The screen is 320px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (min-width: 768px) {
      p {
        font-size: 28px;
      }
    }
    (a) Yes (b) No

Answer key

  1. yellow
  2. makes a link
  3. 60
  4. .red
  5. makes the text bold
  6. False
  7. an id selector
  8. orange
  9. margin
  10. an id selector
  11. on the right
  12. purple
  13. red
  14. 50
  15. CSS
  16. #top
  17. red
  18. CSS
  19. CSS
  20. content
  21. 80
  22. #0000ff
  23. the later one
  24. fits every screen
  25. bright green
  26. packs boxes at the start
  27. 12
  28. space outside the border
  29. <h2 class="star">
  30. colours behind the text
  31. { }
  32. makes headings and lists
  33. sets colours and fonts
  34. #intro
  35. False
  36. font-family
  37. centres a heading
  38. 26
  39. No
  40. No

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