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