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