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

Answer key

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

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