advanced selectors

master
Matt Huntington 8 years ago
parent 2c0176ce11
commit 3b79f6314b

@ -1,6 +1,7 @@
# CSS - Advanced Selectors
## Lesson Objectives
1. Explain why we need advanced selectors
1. List advanced selectors
@ -12,50 +13,56 @@ Advanced selectors help eliminate extra classes. They provide no new functional
### Family Selectors
1. *
- *
- selects everything
- useful for when you want to style everything. Can add an optional ancestor for more specificity
```html
<div>
<a class="style-me">content</a>
<a class="style-me">content</a>
<span class="style-me">content</span>
</div>
```
1. >
```html
<div>
<a class="style-me">content</a>
<a class="style-me">content</a>
<span class="style-me">content</span>
</div>
```
- >
- selects an immediate child
- if you want to add styling to just a child, but the parent has descendants that are similar to child
```html
<ul>
<li>
<ul>
<li></li>
</ul>
</li>
</ul>
```
1. ~
```html
<ul>
<li>
<ul>
<li></li>
</ul>
</li>
</ul>
```
- ~
- sibling selector
- only selects subsequent siblings, not preceding siblings
```html
<h1>Title</h1>
<p>paragraph</p>
<ul>
<li><p>list paragraph</p></li>
</ul>
<p>paragraph</p>
```
1. +
```html
<h1>Title</h1>
<p>paragraph</p>
<ul>
<li><p>list paragraph</p></li>
</ul>
<p>paragraph</p>
```
- +
- immediate sibling selector
- only selects first sibling
```html
<h1>Title</h1>
<p>paragraph</p>
<ul>
<li><p>list paragraph</p></li>
</ul>
<p>paragraph</p>
```
```html
<h1>Title</h1>
<p>paragraph</p>
<ul>
<li><p>list paragraph</p></li>
</ul>
<p>paragraph</p>
```
### Attribute Selectors

Loading…
Cancel
Save