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