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

Answer key

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

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