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