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