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

Answer key

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

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