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

Answer key

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

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