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