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

Answer key

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

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