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