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