← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 405 · 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.📱 min-width: 800px applies when the screen is ___. (a) 800px or narrower (b) turned off (c) 800px or wider (d) exactly 100px
  2. 2.✍️ What value is given to width in this rule?
    h1 {
      margin: 10px;
      width: 300px;
    }
    (a) width (b) red (c) 300px (d) italic
  3. 3.📱 Responsive design means a page ___. (a) never changes (b) fits every screen (c) is only for laptops (d) has no pictures
  4. 4.🎯 Which element does the selector h1 style? (a) <div id="intro"> (b) <h1 class="star"> (c) <h2> (d) <li class="star">
  5. 5.🎨 Which tag holds CSS inside the head? (a) <css> (b) <style> (c) <script> (d) <body>
  6. 6.📱 What does a media query check? (a) the battery level (b) the screen width (c) the time of day (d) the page title
  7. 7.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 460px;
      justify-content: space-between;
    }
    Inside are 4 boxes, each 100px wide (no margins).
  8. 8.🔍 Which is the odd one out? (a) changes the page live (b) reacts to a button click (c) makes a form box (d) counts down a timer
  9. 9.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) the first one (c) neither (d) the later one
  10. 10.✍️ What value is given to font-style in this rule?
    li {
      font-style: italic;
      font-size: 20px;
    }
    (a) italic (b) 20px (c) red (d) font-style
  11. 11.🎯 Which CSS selector matches this element?
    <div class="menu" id="top">Hello</div>
    (a) #intro (b) .menu (c) .top (d) #menu
  12. 12.🎯 Which element does the selector p style? (a) <h1> (b) <li id="logo"> (c) <h2 class="star"> (d) <p class="star">
  13. 13.📱 The screen is 320px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 10px;
      }
    }
    (a) Yes (b) No
  14. 14.⚖️ What colour is the text of this element?
    <p class="note" id="main">Hi</p>
    CSS:
    #main { color: yellow; }
    .note { color: green; }
    p { color: blue; }
    (a) red (b) yellow (c) green (d) blue
  15. 15.🖌️ What colour are the letters?
    li {
      font-size: 32px;
      text-align: left;
      background-color: orange;
      color: black;
    }
    (a) red (b) black (c) orange
  16. 16.📦 In the box model, which part is the gap round content? (a) content (b) border (c) margin (d) padding
  17. 17.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 100px;
      padding: 20px;
      border: 2px solid black;
      margin: 0px;
    }
  18. 18.🌈 Which hex code is magenta? (a) #ff00ff (b) #00ffff (c) #ffff00 (d) #ffffff
  19. 19.✍️ Which property is set to 8px in this rule?
    h1 {
      padding: 8px;
      text-align: center;
    }
    (a) padding (b) font-weight (c) 8px (d) border
  20. 20.✍️ CSS declarations go inside which brackets? (a) { } (b) [ ] (c) < > (d) ( )
  21. 21.What does font-family do? (a) centres a heading (b) makes the text bold (c) picks the font style (d) colours behind the text
  22. 22.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 22px;
      }
    }
  23. 23.🖌️ What colour is behind the letters?
    li {
      text-align: left;
      font-size: 24px;
      background-color: orange;
      color: blue;
    }
    (a) blue (b) orange (c) white
  24. 24.What does text-align do? (a) sets the letter colour (b) picks the font style (c) centres a heading (d) makes letters bigger
  25. 25.📱 The screen is 1366px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 10px;
      }
    }
    (a) No (b) Yes
  26. 26.🎨 Which attribute adds CSS inside one tag? (a) src (b) alt (c) style (d) href
  27. 27.✍️ What is the selector in this CSS rule?
    li {
      margin: 10px;
      color: red;
      font-style: italic;
      font-weight: bold;
    }
    (a) margin (b) li (c) red (d) body
  28. 28.💪 Which flexbox property lines boxes up across? (a) display: flex (b) gap (c) flex-direction (d) align-items
  29. 29.🧩 Which language makes a link? (a) CSS (b) HTML (c) JavaScript
  30. 30.🎯 Can many elements share the same class? (a) No (b) Yes
  31. 31.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 190px;
      justify-content: flex-end;
    }
    Inside are 4 boxes, each 40px wide (no margins).
  32. 32.✍️ What is the selector in this CSS rule?
    .note {
      font-weight: bold;
      color: red;
      text-align: center;
    }
    (a) #top (b) .note (c) font-weight (d) red
  33. 33.✍️ Which property is set to 300px in this rule?
    body {
      text-align: center;
      color: red;
      width: 300px;
      font-weight: bold;
    }
    (a) font-style (b) 300px (c) color (d) width
  34. 34.💪 Which justify-content value equal gaps, none at ends? (a) space-between (b) center (c) flex-end (d) flex-start
  35. 35.🌈 Which colour is rgb(0, 0, 0)? (a) bright green (b) white (c) cyan (d) black
  36. 36.True or false: .menu is a class selector. (a) True (b) False
  37. 37.True or false: CSS rounds box corners. (a) True (b) False
  38. 38.Which of these does HTML do? (a) shows a pop-up message (b) rounds box corners (c) gives the page structure (d) lays out the page
  39. 39.True or false: JavaScript puts a picture on a page. (a) True (b) False
  40. 40.⚖️ Which selector is the weakest? (a) a class selector (b) an id selector (c) an element selector

Answer key

  1. 800px or wider
  2. 300px
  3. fits every screen
  4. <h1 class="star">
  5. <style>
  6. the screen width
  7. 20
  8. makes a form box
  9. the later one
  10. italic
  11. .menu
  12. <p class="star">
  13. Yes
  14. yellow
  15. black
  16. padding
  17. 144
  18. #ff00ff
  19. padding
  20. { }
  21. picks the font style
  22. 22
  23. orange
  24. centres a heading
  25. No
  26. style
  27. li
  28. align-items
  29. HTML
  30. Yes
  31. 30
  32. .note
  33. width
  34. space-between
  35. black
  36. True
  37. True
  38. gives the page structure
  39. False
  40. an element selector

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