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