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