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