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

Answer key

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

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