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

Answer key

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

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