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