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