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

Answer key

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

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