text stringlengths 1 81 | start float64 0 10.1k | duration float64 0 24.9 |
|---|---|---|
it apply to both of these headings. | 2,690.63 | 2.44 |
And, in fact, there is a way to do that. | 2,693.07 | 1.67 |
What we can do is instead of doing
what we might call inline styling, | 2,694.74 | 4.2 |
where we take the CSS
code and place it directly | 2,698.94 | 3.63 |
as an attribute of an HTML
element, we can move our style code | 2,702.57 | 4.59 |
to an entirely different
part of the web page. | 2,707.16 | 3.56 |
Recall again that at the
top of our HTML page, | 2,710.72 | 2.67 |
we have this head section
that just includes | 2,713.39 | 2.67 |
information that's useful
to know about the web page, | 2,716.06 | 2.82 |
but isn't actually part of the
body of the web page, the content | 2,718.88 | 3.18 |
that the user sees. | 2,722.06 | 1.11 |
This head section is
a great place where we | 2,723.17 | 1.8 |
can begin to put some style information,
information about how we would | 2,724.97 | 3.96 |
like for this web page to be styled. | 2,728.93 | 2.97 |
So what I can do here is
instead of putting these style | 2,731.9 | 3.54 |
attributes inside inline
with these HTML elements, | 2,735.44 | 4.71 |
I can inside of the head
section of my web page | 2,740.15 | 3.04 |
add a style element, where in between
the opening style tag and the closing | 2,743.19 | 6.17 |
style tag, I can add any of the
style information that I want. | 2,749.36 | 5.04 |
And here's the way that
syntax is going to look. | 2,754.4 | 2.22 |
I first need to specify, what types
of elements am I going to style? | 2,756.62 | 4.44 |
And in this case, I want
to style all of the h1s. | 2,761.06 | 3.03 |
So I can just say h1. | 2,764.09 | 3.06 |
And then all of the style
code is going to go inside | 2,767.15 | 3.96 |
of a pair of curly braces, where I can
say I would like the color to be blue | 2,771.11 | 4.56 |
and I would like the text
align property to be centered. | 2,775.67 | 4.37 |
So now, here's what I've done. | 2,780.04 | 1.86 |
I've taken the CSS code that used to be
down here inside the body of the page | 2,781.9 | 4.7 |
actually as an attribute
of these h1 elements. | 2,786.6 | 2.91 |
And I've moved the style-related code to
a different part of my page altogether. | 2,789.51 | 5.16 |
Now, the style information is
inside the header of my page, | 2,794.67 | 3.06 |
inside of the style element, where
I've said for every h1 element, | 2,797.73 | 4.51 |
here's how you should style it. | 2,802.24 | 1.4 |
The styling is in between the opening
and curly closing braces here. | 2,803.64 | 3.45 |
And I've said that every h1
should have a color of blue. | 2,807.09 | 3.74 |
And every h1 should have a
text a line property of center. | 2,810.83 | 4.45 |
And that is then going to
apply to all of the h1 elements | 2,815.28 | 3.33 |
that my web page happens to find
inside the body of my web page. | 2,818.61 | 4.08 |
So there's a couple of advantages here. | 2,822.69 | 1.63 |
Advantage number one is what
we talked about a moment ago. | 2,824.32 | 2.45 |
I don't need to duplicate the same
code in both of these h1 elements. | 2,826.77 | 4.17 |
I can write at once and
say, apply this styling | 2,830.94 | 2.55 |
to all of the h1s that
show up in the page. | 2,833.49 | 2.81 |
An advantage number two is we've
been able to factor out the style | 2,836.3 | 4 |
code to somewhere else, just to
make it a little bit cleaner. | 2,840.3 | 3.01 |
So that instead of having a really
long line, you might imagine, | 2,843.31 | 2.78 |
if we had not just two, but maybe
five or six or seven different CSS | 2,846.09 | 3.28 |
properties, that would have taken
up a lot of space on one line. | 2,849.37 | 3.45 |
I can instead in a more
readable, more organized way, | 2,852.82 | 3.26 |
move that style-related
code to the style element | 2,856.08 | 2.91 |
at the beginning of the page
just to make it easier to read, | 2,858.99 | 3.1 |
easier to visually understand, and just
to clean up the body of the web page | 2,862.09 | 3.77 |
as well. | 2,865.86 | 0.9 |
And that's going to be another
of the key themes that's | 2,866.76 | 1.71 |
going to come up again and again in this
class, this idea of separating things | 2,868.47 | 3.3 |
out so that every piece can sort
of be independent of one another. | 2,871.77 | 3.5 |
Our structure of the web page inside
the body is separate from the style. | 2,875.27 | 3.91 |
And we'll see the same sort of idea
appear again and again, as we begin | 2,879.18 | 3.33 |
to try to design web applications well. | 2,882.51 | 3.78 |
So now if I take this exact same page
and go ahead and refresh style.html, | 2,886.29 | 6.36 |
we'll see that we see
the exact same thing. | 2,892.65 | 3.09 |
Both of the headings
still show up as centered. | 2,895.74 | 2.13 |
Both of them still show up as blue. | 2,897.87 | 1.95 |
But now we have the
advantage of having only | 2,899.82 | 1.86 |
written the style code once instead of
needing to write the exact same style | 2,901.68 | 4.17 |
code multiple times in the same way. | 2,905.85 | 3.61 |
But it turns out that we can
even do a little bit better | 2,909.46 | 2.64 |
than this, because one
thing you might imagine | 2,912.1 | 2.7 |
is that if I have a web application or a
website that has multiple different web | 2,914.8 | 3.9 |
pages, it's probably going to be
likely that each of those web pages | 2,918.7 | 4.2 |
might need to be styled in similar ways. | 2,922.9 | 2.43 |
If I have a big banner at
the top of one web page, | 2,925.33 | 2.55 |
then in other pages
related to that page, | 2,927.88 | 2.52 |
I might want the same banner,
styled in the same way, | 2,930.4 | 2.79 |
using similar style information. | 2,933.19 | 2.28 |
And right now, our CSS code is
specific to one particular page. | 2,935.47 | 5.43 |
And it's not going to be easy
to then take that same styling | 2,940.9 | 2.94 |
and apply it to another page. | 2,943.84 | 1.53 |
If I wanted to, I'd need to
copy the exact same CSS code, | 2,945.37 | 3.51 |
put it inside of another page. | 2,948.88 | 1.54 |
But then we run into the
same problem of duplication, | 2,950.42 | 2.57 |
where I've now had to repeat myself
across multiple different pages, | 2,952.99 | 3 |
putting the exact same CSS code
across all those different pages. | 2,955.99 | 4.15 |
So there is an improvement we can make. | 2,960.14 | 1.91 |
And the improvement we can
make is to take that CSS code | 2,962.05 | 3.93 |
and just move it to an
entirely different file. | 2,965.98 | 3.25 |
So instead of putting this style
code inside of a style element | 2,969.23 | 3.65 |
inside of this HTML page,
I'll just create a new file | 2,972.88 | 3.87 |
that I'll call styles.css, inside of
which is going to be all of the CSS | 2,976.75 | 5.52 |
that I care about. | 2,982.27 | 1.08 |
I want to take every h1, I want
to change its color to blue. | 2,983.35 | 3.49 |
And now, I want to change its
text align property to center. | 2,986.84 | 4.51 |
And now, inside of my HTML page, I no
longer need to include any CSS at all. | 2,991.35 | 5.91 |
Instead of this style
element altogether, | 2,997.26 | 2.27 |
I can just link my CSS code in
that CSS file, called styles.css, | 2,999.53 | 5.55 |
to this particular HTML page. | 3,005.08 | 3.06 |
And how do I link the styles.css file? | 3,008.14 | 2.37 |
Well, I can do so again in the
head section of my web page | 3,010.51 | 3.18 |
using a link tag, where I
can say I'd like this link | 3,013.69 | 4.2 |
to be the relationship is it's
going to be a style sheet, | 3,017.89 | 3.85 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.