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

Answer key

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

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