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