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

Answer key

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

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