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