← CSS rules: selector, property, value lesson New set →

CSS Worksheet: CSS Rules and Syntax

HTML and CSS lesson 12: CSS rules: selector, property, value · Set 446 · 40 questions
TalentJR

Code tip (Colon in the middle, semicolon at the end): A rule is: selector { property: value; property: value; } The property is before the colon, the value after it; a semicolon ends each declaration. Count the property: value; lines to count the declarations.

NameDateTime takenScore ___ / 40
  1. 1.✍️ How many declarations (property: value pairs) are in this rule?
    body {
      font-weight: bold;
    }
  2. 2.✍️ What value is given to font-size in this rule?
    p {
      font-size: 20px;
      text-align: center;
      padding: 8px;
      margin: 10px;
    }
    (a) font-size (b) 20px (c) yellow (d) center
  3. 3.✍️ Which sign ends each CSS declaration? (a) : (b) . (c) , (d) ;
  4. 4.✍️ Which property is set to bold in this rule?
    p {
      border: 2px solid;
      text-align: center;
      font-weight: bold;
    }
    (a) width (b) bold (c) border (d) font-weight
  5. 5.✍️ Which property is set to yellow in this rule?
    h1 {
      border: 2px solid;
      background-color: yellow;
      padding: 8px;
    }
    (a) padding (b) yellow (c) margin (d) background-color
  6. 6.✍️ In color: blue; which part is the value? (a) blue (b) : (c) color (d) ;
  7. 7.✍️ What value is given to padding in this rule?
    body {
      text-align: center;
      padding: 8px;
      margin: 10px;
    }
    (a) bold (b) padding (c) 2px solid (d) 8px
  8. 8.✍️ Which property is set to red in this rule?
    .note {
      font-weight: bold;
      margin: 10px;
      color: red;
      width: 300px;
    }
    (a) font-size (b) red (c) text-align (d) color
  9. 9.✍️ What is the selector in this CSS rule?
    li {
      font-size: 20px;
      padding: 8px;
    }
    (a) li (b) 8px (c) font-size (d) body
  10. 10.✍️ What is the selector in this CSS rule?
    h1 {
      border: 2px solid;
      color: red;
      font-style: italic;
      background-color: yellow;
    }
    (a) red (b) border (c) h1 (d) p
  11. 11.✍️ What is the selector in this CSS rule?
    h1 {
      border: 2px solid;
      font-weight: bold;
      font-size: 20px;
      margin: 10px;
    }
    (a) p (b) h1 (c) bold (d) border
  12. 12.✍️ Which property is set to red in this rule?
    p {
      color: red;
      width: 300px;
      padding: 8px;
    }
    (a) font-size (b) color (c) text-align (d) red
  13. 13.✍️ What value is given to border in this rule?
    body {
      background-color: yellow;
      border: 2px solid;
      color: red;
      font-weight: bold;
    }
    (a) 300px (b) 2px solid (c) italic (d) border
  14. 14.✍️ What is the selector in this CSS rule?
    #top {
      margin: 10px;
      border: 2px solid;
      padding: 8px;
      color: red;
    }
    (a) li (b) margin (c) #top (d) 2px solid
  15. 15.✍️ Which property is set to 8px in this rule?
    h1 {
      color: red;
      text-align: center;
      background-color: yellow;
      padding: 8px;
    }
    (a) font-weight (b) border (c) 8px (d) padding
  16. 16.✍️ In color: blue; which part is the property? (a) : (b) ; (c) blue (d) color
  17. 17.✍️ Which sign goes between a property and its value? (a) - (b) = (c) ; (d) :
  18. 18.✍️ What is the selector in this CSS rule?
    #top {
      background-color: yellow;
      text-align: center;
      color: red;
    }
    (a) center (b) li (c) background-color (d) #top
  19. 19.✍️ Which property is set to 2px solid in this rule?
    h2 {
      border: 2px solid;
      background-color: yellow;
      text-align: center;
      margin: 10px;
    }
    (a) 2px solid (b) border (c) width (d) font-style
  20. 20.✍️ Which property is set to yellow in this rule?
    #top {
      background-color: yellow;
      text-align: center;
      margin: 10px;
      font-style: italic;
    }
    (a) margin (b) padding (c) background-color (d) yellow
  21. 21.✍️ How does a CSS comment start? (a) /* (b) <!-- (c) // (d) #
  22. 22.✍️ Which property is set to yellow in this rule?
    h1 {
      margin: 10px;
      text-align: center;
      background-color: yellow;
    }
    (a) yellow (b) padding (c) margin (d) background-color
  23. 23.✍️ What value is given to border in this rule?
    body {
      background-color: yellow;
      border: 2px solid;
      text-align: center;
      color: red;
    }
    (a) border (b) 2px solid (c) 300px (d) italic
  24. 24.✍️ What value is given to width in this rule?
    p {
      width: 300px;
      background-color: yellow;
    }
    (a) width (b) red (c) 300px (d) italic
  25. 25.✍️ CSS declarations go inside which brackets? (a) { } (b) [ ] (c) ( ) (d) < >
  26. 26.✍️ What value is given to font-style in this rule?
    #top {
      background-color: yellow;
      font-style: italic;
    }
    (a) 20px (b) font-style (c) red (d) italic
  27. 27.✍️ What is the selector in this CSS rule?
    .note {
      text-align: center;
      font-size: 20px;
    }
    (a) text-align (b) 20px (c) #top (d) .note
  28. 28.✍️ What is the selector in this CSS rule?
    h1 {
      background-color: yellow;
      font-size: 20px;
      padding: 8px;
    }
    (a) h1 (b) 20px (c) p (d) background-color
  29. 29.✍️ Which property is set to 10px in this rule?
    h1 {
      margin: 10px;
      background-color: yellow;
    }
    (a) font-weight (b) padding (c) 10px (d) margin
  30. 30.✍️ How many declarations (property: value pairs) are in this rule?
    #top {
      font-size: 20px;
      font-style: italic;
      padding: 8px;
      color: red;
    }
  31. 31.✍️ How many declarations (property: value pairs) are in this rule?
    h1 {
      margin: 10px;
      color: red;
      font-weight: bold;
    }
  32. 32.✍️ How many declarations (property: value pairs) are in this rule?
    p {
      width: 300px;
      font-size: 20px;
      font-style: italic;
      color: red;
    }
  33. 33.✍️ What value is given to background-color in this rule?
    li {
      font-weight: bold;
      color: red;
      background-color: yellow;
    }
    (a) yellow (b) background-color (c) 8px (d) 10px
  34. 34.✍️ What is the selector in this CSS rule?
    body {
      font-size: 20px;
      font-style: italic;
    }
    (a) font-size (b) italic (c) body (d) .box
  35. 35.✍️ Which property is set to 20px in this rule?
    body {
      font-size: 20px;
      margin: 10px;
      width: 300px;
      padding: 8px;
    }
    (a) text-align (b) font-size (c) 20px (d) background-color
  36. 36.✍️ How many declarations (property: value pairs) are in this rule?
    .note {
      margin: 10px;
      color: red;
    }
  37. 37.✍️ How many declarations (property: value pairs) are in this rule?
    h1 {
      font-weight: bold;
      text-align: center;
      padding: 8px;
      font-size: 20px;
    }
  38. 38.✍️ What is the selector in this CSS rule?
    li {
      background-color: yellow;
      font-weight: bold;
    }
    (a) body (b) bold (c) li (d) background-color
  39. 39.✍️ What is the selector in this CSS rule?
    h1 {
      border: 2px solid;
      color: red;
      background-color: yellow;
    }
    (a) h1 (b) border (c) p (d) red
  40. 40.✍️ What value is given to font-size in this rule?
    body {
      font-size: 20px;
      border: 2px solid;
      color: red;
    }
    (a) font-size (b) 20px (c) center (d) yellow

Answer key

  1. 1
  2. 20px
  3. ;
  4. font-weight
  5. background-color
  6. blue
  7. 8px
  8. color
  9. li
  10. h1
  11. h1
  12. color
  13. 2px solid
  14. #top
  15. padding
  16. color
  17. :
  18. #top
  19. border
  20. background-color
  21. /*
  22. background-color
  23. 2px solid
  24. 300px
  25. { }
  26. italic
  27. .note
  28. h1
  29. margin
  30. 4
  31. 3
  32. 4
  33. yellow
  34. body
  35. font-size
  36. 2
  37. 4
  38. li
  39. h1
  40. 20px

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