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