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