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

Answer key

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

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