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