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