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