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

Answer key

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

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