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