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

Answer key

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

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