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

Answer key

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

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