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