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