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