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