text
stringlengths
1
81
start
float64
0
10.1k
duration
float64
0
24.9
selecting a class, selecting multiple elements as well.
4,619.37
3.3
It turns out, there are a number of other CSS selectors
4,622.67
2.55
that we can use too.
4,625.22
1.29
So we saw, for example, the multiple element selector,
4,626.51
3.15
like td comma th for selecting table data but also table headers.
4,629.66
5.26
But there's a number of other selectors.
4,634.92
1.67
Here is just a sampling of ones.
4,636.59
1.89
You can specify like descendants or children.
4,638.48
2.73
So if I only want to style divs that are inside of tables,
4,641.21
3.78
or I only want the style lists that are inside of certain classes,
4,644.99
4.17
I can use these defendant and child selectors
4,649.16
2.25
to add styling and those particular ways.
4,651.41
2.79
And there are a number of other CSS selectors we can add as well.
4,654.2
3.89
And we'll go ahead and explore a couple of these,
4,658.09
2.05
just to give you a sample of how some of the CSS selectors can actually work.
4,660.14
5.14
And we'll start by taking a look at the descendent selector, which
4,665.28
3.98
is used to select all of the elements that are descendants
4,669.26
3.18
of some other element, for example.
4,672.44
2.92
So let's go ahead and create a new file, that I'll call descendant.html,
4,675.36
7.07
that again, we'll start with the same code.
4,682.43
3.15
And inside the body of this page, I want an ordered list
4,685.58
3.36
that maybe has a list item 1 and maybe a list item 2.
4,688.94
5.43
And it turns out with lists in HTML, you can nest lists inside of other lists.
4,694.37
5.55
Maybe you've seen bullet points where there's like nested bullets inside
4,699.92
3.09
of other bullet points.
4,703.01
1.17
I can do that here.
4,704.18
1.11
I can add an unordered list and create a sublist, like sublist item 1
4,705.29
6.06
and sublist item 2.
4,711.35
3.12
And maybe down here, here's another list item,
4,714.47
4.13
such as that now I have a couple of items,
4,718.6
2.05
but some that are inside of an unordered sub list.
4,720.65
3.75
Let's go ahead and open up descendent.html
4,724.4
3.18
and see what that looks like.
4,727.58
2.02
So here's what we have.
4,729.6
1.01
We have a list item 1, list item 2, another list item
4,730.61
3.09
that is probably actually list item 3.
4,733.7
5
So we have three items.
4,738.7
1.02
But inside of list item 2, I have an unordered list.
4,739.72
3.81
Let's imagine, for example, that I wanted to only style
4,743.53
4.59
these sublist items as a particular color.
4,748.12
2.93
That maybe I want those to be blue, for example.
4,751.05
3.05
If in the style section of my web page, I
4,754.1
2.81
say that I would like for all list items to be styled blue, well then--
4,756.91
5.73
not styled, colored blue rather--
4,762.64
2.52
then what I'm going to see when I refresh
4,765.16
1.95
the page is that all of the items are going to be blue
4,767.11
3.75
instead of just the two sublist items.
4,770.86
3
But I could instead say that, you know what, I only want list items that
4,773.86
4.65
are children of unordered lists.
4,778.51
2.49
And I can do direct children using this greater than symbol
4,781
2.46
to say that only if there is a ul that immediately contains an li within it,
4,783.46
5.23
then I would like for that to be colored blue.
4,788.69
3.12
And now, if I refresh that, now you'll see that the ordered items, list item
4,791.81
4.19
1, 2, 3, those do not get colored, but only the list items
4,796
4.14
that are inside of the unordered list that
4,800.14
1.95
are directly children of that unordered list
4,802.09
2.88
actually get the CSS styling applied.
4,804.97
2.94
This greater than symbol here is specifying immediate children.
4,807.91
4.37
I could get rid of it, ul li, like this, and this would also work.
4,812.28
3.73
You still see sublist item 1 and 2.
4,816.01
2.24
But this is a more general selector called the descendent selector
4,818.25
3.55
that selects all descendant elements.
4,821.8
1.89
So they might not be the children elements.
4,823.69
1.8
They might be grandchildren element, so to speak,
4,825.49
2.34
if those children elements have other children that
4,827.83
2.76
are attached to them as well.
4,830.59
1.3
Again, for all of this, it's helpful to begin
4,831.89
1.88
to think about things in terms of that Document Object Model, that DOM
4,833.77
3.9
structure, that tree that represented how all of our various different HTML
4,837.67
4.77
elements are related to one another.
4,842.44
3.77
So next up, we can begin to take a look at some of the other selectors
4,846.21
2.92
that we have access to.
4,849.13
1.48
So one of the selectors might be something
4,850.61
2.24
like modifying only on a specific attribute of a particular HTML element.
4,852.85
5.91
So we can use the attribute selector for that.
4,858.76
2.92
I'll create a new file called attribute.html, where here,
4,861.68
5.04
let's go ahead and create a unordered list.
4,866.72
5.1
That's going to have a number of different links
4,871.82
2
to various different websites.
4,873.82
1.62
So here's a list item that is going to be a link to Google.
4,875.44
3.93
So I'll link to google.com and say, Google.
4,879.37
3.99
And I'll go ahead and add a link to facebook.com.
4,883.36
3.84
Call that Facebook.
4,887.2
2.04
And I'll go ahead and add a link to amazon.com and call that Amazon.
4,889.24
6.06
And let's imagine for a moment that I only wanted to style the Facebook link,
4,895.3
4.09
like I want to really highlight the Facebook link,
4,899.39
2.09
tell people to click on that one as by coloring it
4,901.48
2.59
in entirely different color.
4,904.07
2.3
Well, to style things normally, I would say something
4,906.37
3.15
like links should be colored, you know, blue, for example.
4,909.52
4.25
They're colored blue by default, but I could be explicit about it
4,913.77
2.71
and say, links should be color blue like,
4,916.48
1.7
such that now when I open up attribute.html
4,918.18
3.95
all the links are colored blue.
4,922.13
2.96
But I could also say, I would like links that
4,925.09
2.73
have an href attribute of facebook.com, I would like
4,927.82
5.55
those links to be colored red instead.
4,933.37
4.86
So this square bracket notation I can use
4,938.23
2.07
to specify a particular attribute of an HTML element.
4,940.3
3.57
Only anchor tags, a tags, who's href is equal to facebook.com,
4,943.87
3.89