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

Answer key

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

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