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