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

Answer key

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

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