text stringlengths 1 81 | start float64 0 10.1k | duration float64 0 24.9 |
|---|---|---|
So I can say let me add
5 pixels worth of padding | 3,956.73 | 3.48 |
inside of all of my table data
cells and table header cells. | 3,960.21 | 4.05 |
Refresh the page. | 3,964.26 | 1.27 |
And now, here's what the
resulting table looks like. | 3,965.53 | 3.11 |
Just by adding a little
bit of CSS specifying what | 3,968.64 | 2.79 |
border I want around
the edge of the page, | 3,971.43 | 2.22 |
specifying a little bit of padding
inside of each of the cells, | 3,973.65 | 3.3 |
my table now looks a whole lot nicer
than it did just a few lines of code | 3,976.95 | 3.64 |
ago when I just had the HTML
structure of the page and not the CSS | 3,980.59 | 4.34 |
to describe how I actually
wanted that page to be styled. | 3,984.93 | 4.98 |
And notice again that
in doing so, we were | 3,989.91 | 2.07 |
able to use one of these CSS selectors. | 3,991.98 | 3.21 |
I was able to say that I wanted to use
the multiple element selector, which | 3,995.19 | 4.14 |
is just this comma here, to specify
that I would like to apply this styling, | 3,999.33 | 4.26 |
not just to td's but
also to th's as well. | 4,003.59 | 4.89 |
We'll take a look at some
additional examples of CSS selectors | 4,008.48 | 3.6 |
in just a moment. | 4,012.08 | 2.01 |
But next, let's turn our attention
to some more tricky instances | 4,014.09 | 3.72 |
where we might want to apply styling
to multiple elements at the same time. | 4,017.81 | 4.72 |
Let's imagine-- and let's go back to
style.html, where we had some style | 4,022.53 | 4.85 |
code, where I had one heading. | 4,027.38 | 3.01 |
I'll call this Heading 1. | 4,030.39 | 2.82 |
And let's get myself to other
headings, Heading 2 and Heading 3. | 4,033.21 | 4.59 |
All of these now are h1 elements that
are going to show up the same way, | 4,037.8 | 4.71 |
such that now if I style and say, I
would like all h1s to show up with | 4,042.51 | 4.95 |
a color of blue, then when I open
this page where I have three h1 tags, | 4,047.46 | 5.43 |
each of which has a color of
blue, when I open up style.html, | 4,052.89 | 5.37 |
what I'm going to see
is something like this-- | 4,058.26 | 2.3 |
three headings, each of which
happens to have a color of blue. | 4,060.56 | 3.64 |
But what would happen now if I wanted
to style only the first heading. | 4,064.2 | 4.23 |
I want Heading 1 to be blue. | 4,068.43 | 1.84 |
But I don't want to style
Heading 2 and Heading 3. | 4,070.27 | 4.25 |
How do I do that? | 4,074.52 | 1.66 |
Well, one thing we could do is
go back to the inline styling | 4,076.18 | 3.59 |
we did a moment ago, where inside
of h1, I said style color is blue. | 4,079.77 | 5.67 |
And that would say for just
this very first heading, | 4,085.44 | 2.76 |
I would like that to be blue, but
not the other elements at all. | 4,088.2 | 4.08 |
But this again we decided
was not the best design. | 4,092.28 | 2.7 |
This inline styling, commingling of HTML
and CSS just gets a little bit messy. | 4,094.98 | 5.16 |
And it would be nice to be able
to factor all of our style code | 4,100.14 | 2.94 |
to a separate part of
the page altogether. | 4,103.08 | 3.03 |
So how do we do this? | 4,106.11 | 1.27 |
Well, we need some way to uniquely
reference this particular HTML element. | 4,107.38 | 5.41 |
And in order to do so, we
can given HTML element an ID. | 4,112.79 | 4.56 |
An ID is just some unique name
we give to an HTML element, | 4,117.35 | 4.75 |
so that we can reference
it more easily later on. | 4,122.1 | 2.96 |
Let me just go ahead and
give this an ID of Foo. | 4,125.06 | 2.54 |
It could be any idea you want. | 4,127.6 | 1.25 |
But Foo is just a generic name here. | 4,128.85 | 2.19 |
And now, we've given this heading a name
such that in other parts of our page | 4,131.04 | 4.17 |
or in other code, we can reference
and find this particular HTML element. | 4,135.21 | 5.17 |
And in particular now, in the
style section of my web page, | 4,140.38 | 3.26 |
instead of styling all h1
elements, I only want to style | 4,143.64 | 4.32 |
the element that has an ID of Foo. | 4,147.96 | 2.67 |
IDs are by definition unique. | 4,150.63 | 1.62 |
There can only be one element in
this page that has an ID of Foo, | 4,152.25 | 3.56 |
otherwise it's not valid HTML. | 4,155.81 | 2.35 |
And so in order to do so,
we're going to use #Foo. | 4,158.16 | 2.65 |
The hash mark symbol is just CSS's
way of selecting just something | 4,163.43 | 4.06 |
with a particular ID. | 4,167.49 | 1.73 |
So instead of just h1 for
selecting all of the h1 tags, | 4,169.22 | 4.24 |
if I want to select
something by its ID, I | 4,173.46 | 2.16 |
say #Foo to say only style the
element that has an ID of Foo | 4,175.62 | 5.64 |
and give it a color
of blue, for example. | 4,181.26 | 4.26 |
So this style code now will find
something with a particular ID | 4,185.52 | 3.16 |
and give it a style
to correspond with it, | 4,188.68 | 3.28 |
such that now if I reload this
page, only Heading 1 is styled. | 4,191.96 | 4.53 |
Heading 2 and Heading 3 are not. | 4,196.49 | 1.94 |
I've been able to name Heading 1,
give it a name of Foo, an ID of Foo, | 4,198.43 | 4.03 |
and then in my style code, just style
that particular part of my HTML page. | 4,202.46 | 6.91 |
Of course, what if I wanted to style
multiple, but not all of the headings? | 4,209.37 | 4.26 |
Like maybe I want to style
both Heading 1 and Heading 2. | 4,213.63 | 3.84 |
Now, I could use a second ID. | 4,217.47 | 1.54 |
Maybe give us an ID of Bar, for example. | 4,219.01 | 2.63 |
And then style both the element with
ID Foo and the element with ID Bar. | 4,221.64 | 4.53 |
But now we're starting
to add IDs unnecessarily. | 4,226.17 | 3.12 |
I have too many different names. | 4,229.29 | 1.62 |
Things can start to
get messy, especially | 4,230.91 | 1.71 |
as my web pages start to get bigger. | 4,232.62 | 2.37 |
So while IDs are a way of giving a
name to an HTML element that is unique, | 4,234.99 | 5.43 |
sometimes I want to give a name to
an HTML element that is not unique, | 4,240.42 | 4.17 |
some name that can apply to
multiple different HTML elements. | 4,244.59 | 3.84 |
And when we do that,
we call that a class. | 4,248.43 | 2.88 |
An ID is a way of giving a
unique name to an HTML element, | 4,251.31 | 3.54 |
while a class is a way of giving
a name to an HTML element that | 4,254.85 | 3.27 |
might not be unique. | 4,258.12 | 0.9 |
It might apply it to zero or one or
two or more different HTML elements. | 4,259.02 | 5.76 |
So here's what that might look like. | 4,264.78 | 1.74 |
Instead of giving each of these
h1s an ID that's different, | 4,266.52 | 3.54 |
I can give each one a class. | 4,270.06 | 1.74 |
We'll give this a class of Baz,
again, just another arbitrary name | 4,271.8 | 2.94 |
that we've chosen. | 4,274.74 | 1.54 |
And I'll give this each
one a class of Baz as well. | 4,276.28 | 3.93 |
They both belong to the same
class called Baz, in this case. | 4,280.21 | 4.76 |
And now, inside of my style code,
I would like to say just the style | 4,284.97 | 3.96 |
the elements that are of class Baz. | 4,288.93 | 3.05 |
And just as we have a
special symbol, the hashtag, | 4,291.98 | 2.09 |
for styling definitely
something with a particular ID, | 4,294.07 | 3.72 |
to style everything with a
particular class, I can use a dot. | 4,297.79 | 3.9 |
So dot Baz, in this case, is going
to style only the elements that | 4,301.69 | 4.64 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.