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