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