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