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

Answer key

  1. 1
  2. ;
  3. blue
  4. .box
  5. { }
  6. h2
  7. width
  8. color
  9. :
  10. h1
  11. 3
  12. red
  13. .box
  14. #top
  15. .box
  16. .note
  17. 20px
  18. margin
  19. font-style
  20. 300px
  21. .note
  22. font-style
  23. body
  24. 4
  25. .box
  26. center
  27. 3
  28. #top
  29. 3
  30. 300px
  31. 8px
  32. h1
  33. font-style
  34. #top
  35. 2
  36. 8px
  37. 1
  38. 20px
  39. padding
  40. 4

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