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

Answer key

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

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