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

Answer key

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

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