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

Answer key

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

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