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