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