Unit 3.2 CSS Flashcards
Attribute selectors come in handy for styling:
Forms
Define “attribute selector”
The CSS “attribute selector” matches elements based on the presence or value of a given attribute
DRY CSS stands for:
Don’t Repeat Yourself
”>” combinator:
targets a direct child of an element
”+” combinator:
targets an element’s immediate(adjacent) sibling
”~” combinator:
targets all the specified siblings that follow an element
“:first-child” :
represents the first element among a group of sibling elements
“:last-child” :
represents the last element in a group of sibling elements
Define “pseudo” classes
a keyword added to a selector that specifies a special state of the selected element(s)
“:only-child” :
represents an element without any siblings. So targets elements with a single child.
“:empty” :
represents any element that has no children.
”^” : and write example
“begins with” tells the browser to match a piece of code that’s at the beginning of an attribute’s value.
”$” : and write example
“ends with” tells the browser to match a piece of code that’s at the end of attribute’s value.
“*” : and write example
“contains” tells the browser to matcha piece of code that can be any part of an attribute’s value
When do we want to use these types of selectors? (child, attribute, combinators)
- When a CMS or framework allows no access to HTML
- When we are unable to add classes or IDs to elements
- With dynamic lists or image galleries