1842 Week4 Pt2 CSS Selectors
1842 Week4 Pt2 CSS Selectors
https://www.freecodecamp.org/news/css-selectors-cheat-she
et/
Recap
http://
The selector is how we target the element/s we wish to style
http://
www.w3schools.com/css/
css_syntax.asp
Element or tag selectors
slide10.html
Descendent combinator
selects all elements that are descendant (or child) of the
elements with div tag and ‘row’ class
slide11.html
Child combinator
The child combinator (>) is placed between two CSS
selectors. It matches only those elements that are the direct
children of the first.
slide12.html
Adjacent Sibling Selector(+)
It selects the element that is immediately preceded by the former
element. Sibling elements must have the same parent element, and
"adjacent" means "immediately following".
slide13.html
General Sibling Selector ( ~)
The general sibling selector (~) selects all elements that are next
siblings of a specified element. The following example selects all <p>
elements that are next siblings of <div> elements:
slide14.html
Pseudo
selectors &
Pseudo classes
:first-child
The :first-child selector allows you to target the first element
immediately inside another element.
slide16.html
:last-child
The :last-child selector allows you to target the last element
immediately inside another element.
slide16.html
:nth-child()
Target the nth element immediately inside (or child of)
another element. Admits integers, even, odd, or formulas
https://css-tricks.com/almanac/selectors/n/nth-child/
a:not(.name)
Selects all a elements that are not of the .name class