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