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