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