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

Answer key

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

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