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

Answer key

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

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