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