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