1.6 CSS Selectors Flashcards
What’s the purpose of CSS selectors?
CSS selectors let’s us target HTML
by any of its attributes or values.
What are 3 types of CSS attributes?
FIT
- For
- ID
- Type
What 3 characteristics of attributes?
Attributes follow elements
Attributes add specificity
Attributes provide supplemental information
How do you target a class?
Use brackets on the selector

When you target by class, is it changing
attributes inside or outside of the class?
When you target by class, it only changes
those attributes with a class
How do you target a specific class?
specify the class by name
“form-contact” is a specific class within the CSS
Only this class is being targeted

How do you target by ID?
Use ID
Write specific ID name

How do you target by text?

What does the CSS rule do in this example?

Only input fields with values of text that receive the background color
How do you target a placeholder?
Specify placeholder

What is this CSS doing to the placeholder its targeting?

Only input fields with values of placeholder
that receive the background color
How do you target email field?
Specify email

What does the CSS rules do in this scenario?

Only input fields with value of email
that receive the background color
How do you target buttons with CSS attribute selectors?
Specify buttons

How do you target links?
use the a anchors

What is DRY CSS?
Dry stands for
Don’t repeat yourself
Why should you not repeat code?
It makes maintenance difficult
Increase style sheet,
browser works hard
Only define once
How to write more flexible, efficient code?
Create reusable attributes that can be
reapplied in needed areas without duplication
Why shouldn’t you use attribtue selectors?
Slower to interpret by developers
Slower to interpret by browsers
Why are reusable elements useful? Example?
It prevents duplication of identical code.
Example: border radius: adding a curve to border edges

How do you use reusable CSS snippets?
Create reusable class attributes
Add the classes to the HTML
Apply the class to any element that needs that style
In the following example, why do we have
the button attributes both joined and separated in the CSS?

Joined btn class: shared properties
Separated classes: unique properties of buttons
How do you create inline buttons on smaller devices?
Steps
- Add Media Query
- Add CSS

What does this code snippet do on smaller devices?

It makes the buttons appear below each other,
vertically, because of the block display method.











































































