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

Answer key

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

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