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