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