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

Answer key

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

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