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