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

Answer key

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

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