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