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