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

Answer key

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

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