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