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