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