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