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

Answer key

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

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