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