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