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