← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 386 · 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 padding in this rule?
    h2 {
      font-size: 20px;
      padding: 8px;
      font-weight: bold;
      text-align: center;
    }
    (a) 2px solid (b) 8px (c) padding (d) bold
  2. 2.🌈 Which colour is #ff0000? (a) red (b) blue (c) bright green (d) black
  3. 3.Which of these does HTML do? (a) changes the page live (b) makes a link (c) checks a quiz answer (d) reacts to a button click
  4. 4.⚖️ What colour is the text of this element?
    <h1 class="star" id="intro">Hi</h1>
    CSS:
    #intro { color: red; }
    #intro { color: black; }
    (a) red (b) black (c) green (d) blue
  5. 5.⚖️ What colour is the text of this element?
    <p class="red" id="end">Hi</p>
    CSS:
    .red { color: blue; }
    .red { color: green; }
    (a) yellow (b) green (c) blue (d) black
  6. 6.True or false: padding is the gap round content. (a) False (b) True
  7. 7.🎯 Which sign starts an id selector? (a) # (b) & (c) . (d) @
  8. 8.💪 Which flexbox property spaces boxes along a row? (a) align-items (b) gap (c) justify-content (d) flex-direction
  9. 9.True or false: JavaScript gives the page structure. (a) False (b) True
  10. 10.🎯 Which sign starts a class selector? (a) @ (b) & (c) . (d) #
  11. 11.📱 What does a media query check? (a) the battery level (b) the page title (c) the screen width (d) the time of day
  12. 12.✍️ How many declarations (property: value pairs) are in this rule?
    body {
      color: red;
      font-weight: bold;
      background-color: yellow;
      width: 300px;
    }
  13. 13.✍️ What value is given to font-style in this rule?
    .note {
      text-align: center;
      font-style: italic;
    }
    (a) 20px (b) red (c) font-style (d) italic
  14. 14.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 300px;
      justify-content: space-between;
    }
    Inside are 3 boxes, each 60px wide (no margins).
  15. 15.🖌️ Which CSS property sets the letter colour? (a) color (b) background-color (c) text-align (d) font-family
  16. 16.🎯 How many elements on a page should have the same id? (a) 1 (b) any number (c) 5 (d) 2
  17. 17.✍️ How many declarations (property: value pairs) are in this rule?
    p {
      font-size: 20px;
    }
  18. 18.✍️ What is the selector in this CSS rule?
    h2 {
      color: red;
      border: 2px solid;
    }
    (a) 2px solid (b) h1 (c) color (d) h2
  19. 19.⚖️ What colour is the text of this element?
    <h2 class="menu" id="main">Hi</h2>
    CSS:
    .menu { color: green; }
    h2 { color: white; }
    (a) red (b) yellow (c) green (d) white
  20. 20.True or false: the border is space outside the border. (a) True (b) False
  21. 21.🎯 Which CSS selector matches this element?
    <li class="box" id="intro">Hello</li>
    (a) #box (b) .intro (c) div (d) .box
  22. 22.📱 Responsive design means a page ___. (a) fits every screen (b) has no pictures (c) never changes (d) is only for laptops
  23. 23.⚖️ What colour is the text of this element?
    <p class="note" id="top">Hi</p>
    CSS:
    p { color: green; }
    .note { color: blue; }
    (a) green (b) black (c) yellow (d) blue
  24. 24.True or false: margin is space outside the border. (a) True (b) False
  25. 25.🎯 Which element does the selector #top style? (a) <div class="top"> (b) <div id="intro"> (c) <span class="red"> (d) <div id="top">
  26. 26.🎯 Which element does the selector li style? (a) <span class="red"> (b) <li class="red"> (c) <div> (d) <p id="hero">
  27. 27.✍️ In color: blue; which part is the value? (a) : (b) blue (c) color (d) ;
  28. 28.🖌️ What colour are the letters?
    li {
      text-align: left;
      color: white;
      background-color: yellow;
      font-size: 12px;
    }
    (a) white (b) red (c) yellow
  29. 29.✍️ How many declarations (property: value pairs) are in this rule?
    .note {
      font-style: italic;
      color: red;
    }
  30. 30.✍️ CSS declarations go inside which brackets? (a) [ ] (b) { } (c) ( ) (d) < >
  31. 31.True or false: #logo is a class selector. (a) False (b) True
  32. 32.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 18px;
      }
    }
  33. 33.🖌️ What colour is behind the letters?
    li {
      background-color: white;
      font-size: 36px;
      color: green;
      text-align: right;
    }
    (a) green (b) white (c) red
  34. 34.✍️ How many declarations (property: value pairs) are in this rule?
    p {
      background-color: yellow;
      font-weight: bold;
      font-size: 20px;
    }
  35. 35.🎯 Which element does the selector p style? (a) <p class="note"> (b) <h1> (c) <h2 class="note"> (d) <li id="intro">
  36. 36.📦 In the box model, which part is the gap round content? (a) content (b) border (c) padding (d) margin
  37. 37.True or false: the border is the gap to other boxes. (a) True (b) False
  38. 38.✍️ How many declarations (property: value pairs) are in this rule?
    h2 {
      color: red;
      font-style: italic;
      width: 300px;
    }
  39. 39.🌈 Which hex code is white? (a) #ff00ff (b) #ffffff (c) #ff0000 (d) #0000ff
  40. 40.What does text-align do? (a) picks the font style (b) makes the text bold (c) sets the letter colour (d) centres a heading

Answer key

  1. 8px
  2. red
  3. makes a link
  4. black
  5. green
  6. True
  7. #
  8. justify-content
  9. False
  10. .
  11. the screen width
  12. 4
  13. italic
  14. 60
  15. color
  16. 1
  17. 1
  18. h2
  19. green
  20. False
  21. .box
  22. fits every screen
  23. blue
  24. True
  25. <div id="top">
  26. <li class="red">
  27. blue
  28. white
  29. 2
  30. { }
  31. False
  32. 24
  33. white
  34. 3
  35. <p class="note">
  36. padding
  37. False
  38. 3
  39. #ffffff
  40. centres a heading

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