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