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