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