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

Answer key

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

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