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

Answer key

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

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