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