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