Element (type) selectors

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

This Element (type) selectors worksheet is part of the HTML and CSS Journey journey. Print it as a booklet?

Element (type) selectors

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. What syntax does an element selector use?
A The lowercase HTML tag name: p, h1, a
B A dot followed by the tag name: .p, .h1
2. What does p { color: blue; } target?
A Every <p> element on the page
B Only the first <p> element
3. True or false: element selectors are the most specific type of CSS selector.
A True
B False
4. Which is the correct CSS syntax for an element selector?
A h1: { font-size: 2em; }
B h1 { font-size: 2em; }
5. True or false: a { text-decoration: none; } removes the underline from all links.
A True
B False

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1p { color: red; } ATargets every <h1> element and sets its size and colour — applies to all instances on the page
2h1 { font-size: 2em; color: darkblue; } BCSS declarations require a colon between property and value — it should be color: red;
3An element selector uses the lowercase HTML tag name with no prefix Cp { color: blue; }
4Element selectors are the least specific — class and id selectors override them DElement selectors should be lowercase — use 'p' not 'P' to match HTML convention
5P { color: red; } Ea { text-decoration: none; }
6p { color red; } FTargets every <p> element on the page and sets its text colour to red

Definitions

p { }

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
_ { color: red; }
2.
__ { font-size: 32px; }
3.
p { _____: navy; }
4.
_ { text-decoration: none; }
5.
__ { list-style: none; }

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A P { color: red; }
B h2 { font-size: 24px; }
C a { text-decoration: none; }
Question 2
A p { color: blue; }
B h1 { color red; }
C a { color: green; }
Question 3
A p { color: navy; }
B h2 { font-weight: bold; }
C a { text-decoration none; }
Question 4
A p { color: red; }
B h1 { font-size: 32px; }
C ul { list-style: disc; }
D li { color blue; }
Question 5
A p { margin: 0; }
B h2 { color: navy; }
C ul { padding: 0; }
D li { list-style: none; }
E a { color red; }

Answer Key

Element (type) selectors
Section A: Quick Questions
Q1
A — The lowercase HTML tag name: p, h1, a
Q2
A — Every <p> element on the page
Q3
B — False
Q4
B — h1 { font-size: 2em; }
Q5
A — True
Section B: Match the Pairs
Q1
p { color: red; } → Targets every <p> element on the page and sets its text colour to red
Q2
h1 { font-size: 2em; color: darkblue; } → Targets every <h1> element and sets its size and colour — applies to all instances on the page
Q3
An element selector uses the lowercase HTML tag name with no prefix → a { text-decoration: none; }
Q4
Element selectors are the least specific — class and id selectors override them → p { color: blue; }
Q5
P { color: red; } → Element selectors should be lowercase — use 'p' not 'P' to match HTML convention
Q6
p { color red; } → CSS declarations require a colon between property and value — it should be color: red;
Section C: Definitions
Q1
p { } — An element selector that targets every <p> element on the page. The tag name is used directly as the selector, followed by a CSS declaration block.
Section D: Fill in the Blanks
Q1
p { color: red; }
Q2
h1 { font-size: 32px; }
Q3
p { color: navy; }
Q4
a { text-decoration: none; }
Q5
ul { list-style: none; }
Section E: Spot the Error
Q1
A — CSS element selectors should be lowercase. 'P' should be written as 'p'.
Q2
B — CSS property-value pairs require a colon separator. It should be color: red; not color red;
Q3
C — CSS property-value pairs require a colon separator. It should be text-decoration: none; not text-decoration none;
Q4
D — CSS property-value pairs require a colon separator. It should be color: blue; not color blue;
Q5
E — CSS property-value pairs require a colon separator. It should be color: red; not color red;