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