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

Answer key

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

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