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

Answer key

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

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