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