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

Answer key

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

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