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

Answer key

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

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