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