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