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

Answer key

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

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