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

Answer key

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

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