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