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