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