Selectors Flashcards
Type selector vs. Universal selector
Type selector selects all elements by their tag
Universal selector selects all element
What symbol does the universal selector use?
*
Class attribute
Applied to HTML code, it is used to select things in CSS
For example:
< p class = “brand” > Shoe Company < / p >
How do you select something from the class attribute in CSS
Dot then the text
For example:
.brand {
}
How would you add multiple classes to an HTML element
Separate them with a space
For example:
< p class = “ green bold “ >Green and bold text< / p >
Class vs. Id attribute
Class can be used for multiple elements
ID can only be used for one element
How do you select an element’s ID for CSS
Put a # in front of the name
How do you use the <em>attribute selector</em>
Surround the attribute you want to target with brackets in CSS For example: [href] { color: magenta; }
How do you select attributes with a specific value?
type[attribute*=value} For example: <em>For < img src='summer' /></em> img[src*='summer'] { height: 50px; }
What are pseudo-class selectors?
A line of code that changes the appearance of certain elements for user interactions
For example:
An anchor element turning purple after you click on it
How do you attach a pseudo-class to a selector?
Put the element name, colon, and then the name of the pseudo-class For example: p:hover { background color: lime; }
What does the hover pseudo-class do?
Changes something when you hover over it with your mouse
For example:
If you hover over an anchor it will change color
How to give an element a background color?
With the <em>background-color:</em>
Order of specificity for CSS (highest to lowest)
ID, class, type
What is chaining?
Combing CSS selectors