0
0
CSSmarkup~5 mins

Element selectors in CSS - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is an element selector in CSS?
An element selector targets all HTML elements of a specific type to apply styles. For example, p selects all paragraph elements.
Click to reveal answer
beginner
How do you write a CSS rule to change the text color of all h1 elements to blue?
Use the element selector h1 like this:<br>
h1 {<br>  color: blue;<br>}
Click to reveal answer
beginner
True or False: Element selectors apply styles only to elements with a specific class.
False. Element selectors apply styles to all elements of that type, regardless of class or id.
Click to reveal answer
beginner
What will this CSS do?<br>
div { background-color: lightgray; }
It will set the background color of all div elements on the page to light gray.
Click to reveal answer
intermediate
Why should you be careful when using element selectors on large pages?
Because element selectors style every element of that type, they can affect many parts of the page and may cause unexpected changes if not used carefully.
Click to reveal answer
Which CSS selector targets all p elements?
A#p
B.p
C*p
Dp
What does this CSS rule do?<br>
h2 { font-weight: bold; }
AMakes all elements with class 'h2' bold
BMakes all <code>h2</code> elements bold
CMakes all elements with id 'h2' bold
DDoes nothing
If you want to style only one specific element, should you use an element selector?
ANo, element selectors target all elements of that type
BYes, element selectors target single elements
CYes, but only if the element has a class
DNo, element selectors only work with ids
Which selector would you use to style all button elements?
Abutton
B#button
C*button
D.button
What is a potential downside of using element selectors on a large website?
AThey only style one element
BThey are slower than class selectors
CThey can unintentionally style many elements and cause layout issues
DThey don't work in modern browsers
Explain what an element selector is and give an example of how to use it in CSS.
Think about how you select all paragraphs or headings in CSS.
You got /3 concepts.
    Describe a situation where using an element selector might cause problems on a webpage.
    Consider what happens if you style all <code>div</code> or <code>p</code> elements without limits.
    You got /3 concepts.