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