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