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