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

Answer key

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

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