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