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