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