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