Element (type) selectors, online
Six activities your students do on their own devices. See who's finished, and their scores.
Element (type) selectors in one minute
What students need to know
'a' is the HTML tag name used directly as a CSS selector. No dot or hash prefix — that's the element selector pattern. This p rule can be overridden by a .intro { color: red } class rule or a #lead { color: green } ID rule.
Element selectors are global — they apply to every element of that type on the page, not just the first one. Element selectors have the lowest specificity. Class selectors (0,1,0) and ID selectors (1,0,0) override them.
Mistakes students make
- CSS element selectors should be lowercase. 'P' should be written as 'p'.
- CSS property-value pairs require a colon separator. It should be color: red; not color red;.
- CSS property-value pairs require a colon separator. It should be text-decoration: none; not text-decoration none;.
- CSS property-value pairs require a colon separator. It should be color: blue; not color blue;.
What students will learn in this module
Every question in Module 35
Quick questions
- What syntax does an element selector use?AThe lowercase HTML tag name: p, h1, aBA dot followed by the tag name: .p, .h1
- What does p { color: blue; } target?AEvery <p> element on the pageBOnly the first <p> element
- True or false: element selectors are the most specific type of CSS selector.ATrueBFalse
- Which is the correct CSS syntax for an element selector?Ah1: { font-size: 2em; }Bh1 { font-size: 2em; }
- True or false: a { text-decoration: none; } removes the underline from all links.ATrueBFalse
Key terms
Students type the meaning of:
p { }
Match the pairs
p { color: red; }Match it to what it doesh1 {
font-size: 2em;
color: darkblue;
}Match it to what it doesAn element selector uses the lowercase HTML tag name with no prefixMatch it to what it doesElement selectors are the least specific — class and id selectors override themMatch it to what it doesP { color: red; }Match it to what it doesp { color red; }Match it to what it doesFill in the blanks
_ { color: red; }Hint: Type the HTML element name used as a CSS selector to style all paragraphs
__ { font-size: 32px; }Hint: Type the HTML element name used as a CSS selector to style all level-1 headings
p { _____: navy; }Hint: Type the CSS property name that sets the text colour of an element
_ { text-decoration: none; }Hint: Type the HTML element name used as a CSS selector to style all links
__ { list-style: none; }Hint: Type the HTML element name used as a CSS selector to style all unordered lists
Spot the error
Question 1
AP { color: red; }Bh2 { font-size: 24px; }Ca { text-decoration: none; }
Question 2
Ap { color: blue; }Bh1 { color red; }Ca { color: green; }
Question 3
Ap { color: navy; }Bh2 { font-weight: bold; }Ca { text-decoration none; }
Question 4
Ap { color: red; }Bh1 { font-size: 32px; }Cul { list-style: disc; }Dli { color blue; }
Question 5
Ap { margin: 0; }Bh2 { color: navy; }Cul { padding: 0; }Dli { list-style: none; }Ea { color red; }
