Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,780 --> 00:00:02,719
In this lecture,
2
00:00:02,719 --> 00:00:07,437
we will learn about six properties to style text with CSS.
3
00:00:09,530 --> 00:00:11,350
And let's just quickly recap
4
00:00:11,350 --> 00:00:13,670
what we did in the last lecture.
5
00:00:13,670 --> 00:00:18,320
So we are writing external CSS in this CSS file
6
00:00:18,320 --> 00:00:23,320
and the CSS file is always composed of multiple CSS rules.
7
00:00:24,310 --> 00:00:27,560
So right now we only have one CSS rule,
8
00:00:27,560 --> 00:00:31,380
but, of course, we will now start adding more of them.
9
00:00:31,380 --> 00:00:35,530
Now, a CSS rule always starts with a selector.
10
00:00:35,530 --> 00:00:39,430
So in this case, we are selecting the h1 element,
11
00:00:39,430 --> 00:00:41,900
but if there were more h1 elements,
12
00:00:41,900 --> 00:00:45,410
then the selector would actually select all of them.
13
00:00:45,410 --> 00:00:48,480
Then we have this declaration block here
14
00:00:48,480 --> 00:00:52,030
into which we can write one or more declarations
15
00:00:52,030 --> 00:00:53,270
like this one
16
00:00:53,270 --> 00:00:56,890
and each declaration has this property name.
17
00:00:56,890 --> 00:00:58,510
So in this case, the color,
18
00:00:58,510 --> 00:01:02,200
and then the value that we specify for that property,
19
00:01:02,200 --> 00:01:05,453
which in this case is this keyword of blue.
20
00:01:07,060 --> 00:01:10,750
And so now we will start adding some more properties here.
21
00:01:10,750 --> 00:01:14,783
And the first one that I want to use is the font size.
22
00:01:16,570 --> 00:01:21,160
So here we can basically specify the size of the text
23
00:01:21,160 --> 00:01:25,460
and each property can take different types of values,
24
00:01:25,460 --> 00:01:28,500
such as length or keywords.
25
00:01:28,500 --> 00:01:32,010
So you see that here in the color, the value is a keyword,
26
00:01:32,010 --> 00:01:36,180
but now here in the font size, we actually need a length.
27
00:01:36,180 --> 00:01:40,110
So basically, the size of the text, in this case.
28
00:01:40,110 --> 00:01:44,460
Now we can specify length using different units in CSS,
29
00:01:44,460 --> 00:01:46,950
but don't worry about that for now.
30
00:01:46,950 --> 00:01:50,500
So for now, we will simply use the very simplest one,
31
00:01:50,500 --> 00:01:53,560
which is pixels on your screen.
32
00:01:53,560 --> 00:01:57,440
So we can specify the font size, for example, 26 pixels,
33
00:01:59,210 --> 00:02:01,060
then add a semi-colon here.
34
00:02:01,060 --> 00:02:03,340
And so now the text on the screen
35
00:02:03,340 --> 00:02:08,340
will be exactly 26 pixels of your physical screen.
36
00:02:08,460 --> 00:02:10,252
So if I give this a save now,
37
00:02:11,400 --> 00:02:14,660
then you see that the text here decreased.
38
00:02:14,660 --> 00:02:17,340
And just remember that in case it didn't update
39
00:02:17,340 --> 00:02:21,240
on your computer and you are successfully connected
40
00:02:21,240 --> 00:02:24,320
to the live server, as you can see down here,
41
00:02:24,320 --> 00:02:28,000
then just manually reload the page here once.
42
00:02:28,000 --> 00:02:31,980
And then in the successful updates here of the code,
43
00:02:31,980 --> 00:02:35,350
it will then automatically reload your page.
44
00:02:35,350 --> 00:02:39,960
But anyway, let's now start adding the next property,
45
00:02:39,960 --> 00:02:43,280
which is the font family.
46
00:02:43,280 --> 00:02:45,470
And so here you can specify
47
00:02:45,470 --> 00:02:47,930
basically different fonts for your text.
48
00:02:47,930 --> 00:02:50,500
So just like you can specify a font
49
00:02:50,500 --> 00:02:54,980
in something like a Word document or a Google Page document,
50
00:02:54,980 --> 00:02:57,620
you can do the same in CSS.
51
00:02:57,620 --> 00:03:00,710
However, what's different in the case of CSS
52
00:03:00,710 --> 00:03:03,290
is that you cannot simply use a font family
53
00:03:03,290 --> 00:03:05,560
that you have installed on your computer
54
00:03:05,560 --> 00:03:08,570
because that wouldn't then work for all the users
55
00:03:08,570 --> 00:03:11,110
that are going to visit your page in the future,
56
00:03:11,110 --> 00:03:14,683
unless they also have that font installed on the computer.
57
00:03:16,100 --> 00:03:17,833
So there is a solution for that
58
00:03:17,833 --> 00:03:19,740
that we will talk about later,
59
00:03:19,740 --> 00:03:23,130
but for now we will simply not actually specify
60
00:03:23,130 --> 00:03:27,000
a real font family, but instead just use the keyword
61
00:03:27,000 --> 00:03:30,040
that we want the browser to use any font size
62
00:03:30,040 --> 00:03:32,340
that is a sans serif.
63
00:03:32,340 --> 00:03:36,300
And sans serif, we will also learn a little bit later
64
00:03:36,300 --> 00:03:37,770
what that actually means,
65
00:03:37,770 --> 00:03:41,240
so in the design section of this course,
66
00:03:41,240 --> 00:03:44,380
but if we give this now a save,
67
00:03:44,380 --> 00:03:47,673
you see that this font here changed completely.
68
00:03:48,800 --> 00:03:51,190
So now it looks more clean,
69
00:03:51,190 --> 00:03:54,780
but what matters is that now as we update our page,
70
00:03:54,780 --> 00:03:58,150
in fact, the font family here of this heading
71
00:03:58,150 --> 00:03:59,593
now looks very different.
72
00:04:00,690 --> 00:04:02,870
So it no longer has these serifs,
73
00:04:02,870 --> 00:04:05,320
which are like these small things here
74
00:04:05,320 --> 00:04:07,053
at the end of the letters.
75
00:04:08,490 --> 00:04:12,120
And again, later, in the design section, we will then learn
76
00:04:12,120 --> 00:04:16,930
how we can specify specific font families for our pages.
77
00:04:16,930 --> 00:04:20,110
But now let's take a look at our next property here
78
00:04:20,110 --> 00:04:23,293
for text, which is text transform.
79
00:04:24,920 --> 00:04:26,540
And so with text transform,
80
00:04:26,540 --> 00:04:29,983
we can basically turn a text uppercase.
81
00:04:30,950 --> 00:04:32,810
So you can see, one more time,
82
00:04:32,810 --> 00:04:36,640
the VS Code gives us a lot of suggestions here,
83
00:04:36,640 --> 00:04:38,160
so this whole list.
84
00:04:38,160 --> 00:04:41,363
And so the most used one here is actually uppercase.
85
00:04:42,680 --> 00:04:45,530
So uppercase, like this,
86
00:04:45,530 --> 00:04:49,210
and the result is exactly what you would expect.
87
00:04:49,210 --> 00:04:52,120
So all the text simply turn uppercase.
88
00:04:52,120 --> 00:04:54,180
So this is a simple one.
89
00:04:54,180 --> 00:04:57,953
And now let's try another one which is called font style.
90
00:05:00,160 --> 00:05:02,397
And here again, you see these options.
91
00:05:02,397 --> 00:05:04,610
The most used one, in this case,
92
00:05:04,610 --> 00:05:06,943
is to set some text to italic.
93
00:05:08,500 --> 00:05:10,480
So let's check that out,
94
00:05:10,480 --> 00:05:13,890
and indeed, that is just what happened.
95
00:05:13,890 --> 00:05:17,440
So the text turned italic, as expected.
96
00:05:17,440 --> 00:05:21,040
Great, so we already covered four properties
97
00:05:21,040 --> 00:05:24,040
and some of its possible values here.
98
00:05:24,040 --> 00:05:26,020
So we're making good progress.
99
00:05:26,020 --> 00:05:29,150
And of course, as I mentioned before, you do not have
100
00:05:29,150 --> 00:05:32,100
to start memorizing these properties here now.
101
00:05:32,100 --> 00:05:34,070
You will get used to them over time
102
00:05:34,070 --> 00:05:36,543
as you start using them more and more.
103
00:05:38,590 --> 00:05:41,500
And let's actually get rid one of this one here,
104
00:05:41,500 --> 00:05:43,730
because we will actually talk about colors
105
00:05:43,730 --> 00:05:44,973
a little bit later.
106
00:05:46,820 --> 00:05:50,980
Okay, so let's now go to our next headings.
107
00:05:50,980 --> 00:05:53,853
So let's now style our h2 element.
108
00:05:54,780 --> 00:05:59,523
So that is this basically main heading of this article.
109
00:06:01,407 --> 00:06:04,600
And so we can use the properties that we already learned.
110
00:06:04,600 --> 00:06:07,880
And so if you keep typing these property names,
111
00:06:07,880 --> 00:06:10,300
they will start getting into your brain.
112
00:06:10,300 --> 00:06:14,143
So this one, let's actually make it even bigger than the h1.
113
00:06:16,260 --> 00:06:19,420
So really big, like 40 pixels,
114
00:06:19,420 --> 00:06:21,510
and that's no problem at all.
115
00:06:21,510 --> 00:06:25,230
So just because the h1 is the main heading of the page,
116
00:06:25,230 --> 00:06:28,690
it doesn't mean that it also needs to be the biggest one.
117
00:06:28,690 --> 00:06:32,570
So being the h1 is really all about semantics,
118
00:06:32,570 --> 00:06:34,763
not only about what it looks like.
119
00:06:36,190 --> 00:06:38,910
So we have a nice big text
120
00:06:38,910 --> 00:06:42,163
and now let's just make it also sans serif,
121
00:06:43,190 --> 00:06:45,963
so giving it this modern look and feel.
122
00:06:47,460 --> 00:06:50,263
So the sans serif keyword,
123
00:06:52,050 --> 00:06:54,120
and here we go.
124
00:06:54,120 --> 00:06:57,453
Next up let's style our paragraphs.
125
00:06:58,290 --> 00:07:00,470
And so, as I mentioned before,
126
00:07:00,470 --> 00:07:03,380
by selecting the p element like this,
127
00:07:03,380 --> 00:07:05,880
this will actually select all the p elements
128
00:07:05,880 --> 00:07:08,450
that are on our page.
129
00:07:08,450 --> 00:07:11,830
So this paragraph here and this and this,
130
00:07:11,830 --> 00:07:15,443
and really all the ones that we have here on the page.
131
00:07:17,910 --> 00:07:20,203
So let's give it again a font size,
132
00:07:21,470 --> 00:07:24,020
let's say of 22 pixels.
133
00:07:24,020 --> 00:07:26,170
And for now, all of these lengths here,
134
00:07:26,170 --> 00:07:28,950
so all of these numbers that I've been using
135
00:07:28,950 --> 00:07:30,310
are kind of random,
136
00:07:30,310 --> 00:07:33,630
but later we will also learn how we can use a system
137
00:07:33,630 --> 00:07:36,130
so that we can basically automatically
138
00:07:36,130 --> 00:07:39,353
figure out which font sizes we should use.
139
00:07:42,120 --> 00:07:46,913
Now I also want to change the font family again,
140
00:07:48,870 --> 00:07:51,443
and once again, using sans serif,
141
00:07:52,720 --> 00:07:56,020
and nice, that looks very nice already.
142
00:07:56,020 --> 00:07:58,970
And if we compare it with our demo,
143
00:07:58,970 --> 00:08:02,970
then we can see that we start getting closer
144
00:08:02,970 --> 00:08:05,710
to, or yeah, to our demo page,
145
00:08:05,710 --> 00:08:08,073
so what we want to achieve in the end.
146
00:08:10,930 --> 00:08:13,270
There is actually just one more thing
147
00:08:13,270 --> 00:08:15,680
that I want to change here in the paragraphs,
148
00:08:15,680 --> 00:08:19,040
which is to specify yet another new property,
149
00:08:19,040 --> 00:08:20,603
which is the line height.
150
00:08:21,900 --> 00:08:26,040
So I will first actually specify it.
151
00:08:26,040 --> 00:08:29,590
And then you will see the difference in the text.
152
00:08:29,590 --> 00:08:33,222
So here we actually use a value without a unit.
153
00:08:34,150 --> 00:08:37,250
So in this case, this 1.5 simply means
154
00:08:37,250 --> 00:08:41,453
that the line height will be 1.5 times the font size.
155
00:08:43,250 --> 00:08:46,210
So by default, the line height is simply one,
156
00:08:46,210 --> 00:08:50,070
but now if we set it to 1.5, then you should see the space
157
00:08:50,070 --> 00:08:52,890
between the lines here increase
158
00:08:52,890 --> 00:08:55,030
between here and here and here.
159
00:08:55,030 --> 00:08:57,680
So look closely at that as I now click here
160
00:08:57,680 --> 00:08:59,733
to reload the page,
161
00:09:00,990 --> 00:09:03,053
and you'll see that really changed.
162
00:09:05,180 --> 00:09:08,460
And we could set it even higher, of course,
163
00:09:08,460 --> 00:09:10,720
and then we would get even more space,
164
00:09:10,720 --> 00:09:12,823
but already looks a bit too much.
165
00:09:14,170 --> 00:09:17,973
So let's go back to 1.5, like this.
166
00:09:19,450 --> 00:09:23,010
Now, by the way, something quite interesting happened here
167
00:09:23,010 --> 00:09:25,110
that maybe you noticed.
168
00:09:25,110 --> 00:09:29,070
So remember how inside of these paragraphs
169
00:09:29,070 --> 00:09:32,760
that we just styled, we have different elements
170
00:09:32,760 --> 00:09:34,970
such as this italic text,
171
00:09:34,970 --> 00:09:39,200
which is an em element, remember?
172
00:09:39,200 --> 00:09:42,650
So here in this paragraph,
173
00:09:42,650 --> 00:09:45,630
for example, we have the em element,
174
00:09:45,630 --> 00:09:49,773
or here in this paragraph, we have the strong element.
175
00:09:51,340 --> 00:09:53,093
Or down here we have the anchor,
176
00:09:55,970 --> 00:09:57,793
so this element right here.
177
00:09:59,350 --> 00:10:02,890
And as you can see, these elements here on the page,
178
00:10:02,890 --> 00:10:05,790
so for example, this anchor here
179
00:10:05,790 --> 00:10:07,920
somehow got the same font size
180
00:10:07,920 --> 00:10:11,290
and the same font family as the p element,
181
00:10:11,290 --> 00:10:15,600
even though we did not specify these styles
182
00:10:15,600 --> 00:10:17,300
for the link anywhere.
183
00:10:17,300 --> 00:10:21,110
So we didn't specify the font size and the family
184
00:10:21,110 --> 00:10:24,330
and the line height, not for the anchor,
185
00:10:24,330 --> 00:10:27,690
not for strong text,
186
00:10:27,690 --> 00:10:29,260
or not for strong elements,
187
00:10:29,260 --> 00:10:31,753
and also not for the em element.
188
00:10:33,100 --> 00:10:36,553
But still they got these styles applied to them somehow.
189
00:10:38,041 --> 00:10:39,230
And the reason for this
190
00:10:39,230 --> 00:10:43,200
is a very important mechanism called inheritance.
191
00:10:43,200 --> 00:10:45,990
Now this is a little bit complex to understand.
192
00:10:45,990 --> 00:10:47,980
And so we will have a whole lecture
193
00:10:47,980 --> 00:10:50,550
on inheritance a little bit later,
194
00:10:50,550 --> 00:10:53,380
but still I wanted to already show you this effect
195
00:10:53,380 --> 00:10:55,643
in action here at this point.
196
00:10:56,650 --> 00:11:01,650
But anyway, let's now keep styling or reminding elements.
197
00:11:01,710 --> 00:11:04,400
So starting with h3,
198
00:11:04,400 --> 00:11:08,230
and let's put that here after the h2
199
00:11:09,340 --> 00:11:12,763
to group our rules here in a logical way.
200
00:11:13,770 --> 00:11:18,770
So the font size in this one, let's make it like 30 pixels.
201
00:11:19,750 --> 00:11:24,750
So that's going to be this one here, exactly.
202
00:11:24,910 --> 00:11:26,650
And this one.
203
00:11:26,650 --> 00:11:29,640
So again, we have multiple h3 elements.
204
00:11:29,640 --> 00:11:32,500
And so by using the h3 selector here,
205
00:11:32,500 --> 00:11:34,203
we will select all of them.
206
00:11:36,870 --> 00:11:39,470
Now, just the font family again,
207
00:11:39,470 --> 00:11:43,073
and setting it to sans serif.
208
00:11:44,680 --> 00:11:46,210
All right.
209
00:11:46,210 --> 00:11:50,450
And now finally, we have the h4 heading.
210
00:11:50,450 --> 00:11:51,793
So that's this one here.
211
00:11:55,650 --> 00:12:00,060
So let's again set the font size
212
00:12:00,060 --> 00:12:01,543
and the font family,
213
00:12:03,220 --> 00:12:04,730
so 20 pixels
214
00:12:07,560 --> 00:12:10,253
and here sans serif.
215
00:12:11,230 --> 00:12:15,563
And actually, let's also turn the text uppercase here.
216
00:12:17,830 --> 00:12:22,830
And remember how we use the text transform property
217
00:12:22,960 --> 00:12:23,793
for that.
218
00:12:24,680 --> 00:12:28,283
If we set it to uppercase like this,
219
00:12:29,540 --> 00:12:30,630
nice.
220
00:12:30,630 --> 00:12:33,570
And now there is just one final property
221
00:12:33,570 --> 00:12:37,510
that I want to show you to basically style text,
222
00:12:37,510 --> 00:12:40,230
which is that we can also align text.
223
00:12:40,230 --> 00:12:44,090
So again, a little bit like we can do in Microsoft Word
224
00:12:44,090 --> 00:12:47,300
or in Google Pages or something like that.
225
00:12:47,300 --> 00:12:51,190
And so for that, we use the text align property.
226
00:12:51,190 --> 00:12:53,373
And again, you can see the options here.
227
00:12:56,070 --> 00:12:57,810
One interesting one that we can use
228
00:12:57,810 --> 00:13:00,360
is to align the text to the center.
229
00:13:00,360 --> 00:13:03,333
And so guess what will happen now when I save it?
230
00:13:05,790 --> 00:13:08,170
Well, we need to go down here again
231
00:13:08,170 --> 00:13:12,260
and you see that now it is in the center of the page.
232
00:13:12,260 --> 00:13:16,370
And technically it is in the center of its parent element,
233
00:13:16,370 --> 00:13:20,700
but that parent element basically occupies this entire page,
234
00:13:20,700 --> 00:13:24,730
and so therefore it is now at the center of the page.
235
00:13:24,730 --> 00:13:25,840
All right.
236
00:13:25,840 --> 00:13:28,680
And so now the only thing that we are missing
237
00:13:28,680 --> 00:13:32,130
is these list items here.
238
00:13:32,130 --> 00:13:34,623
So all of these five and these three,
239
00:13:35,690 --> 00:13:38,680
and also these anchors, so the links,
240
00:13:38,680 --> 00:13:41,050
but we will style the links a little bit later
241
00:13:41,050 --> 00:13:44,810
because there are some special cases for links.
242
00:13:44,810 --> 00:13:46,460
So let's just finish this video
243
00:13:46,460 --> 00:13:49,003
by styling these li elements.
244
00:13:49,960 --> 00:13:50,793
All right.
245
00:13:51,640 --> 00:13:52,973
Let's do that down here,
246
00:13:54,640 --> 00:13:59,500
and notice how we do not style the ol element
247
00:13:59,500 --> 00:14:01,410
and the ul element
248
00:14:01,410 --> 00:14:04,653
that are the parent elements of the list items.
249
00:14:06,530 --> 00:14:11,530
So remember that the list itself is an ol
250
00:14:11,530 --> 00:14:13,300
or it is a ul,
251
00:14:13,300 --> 00:14:16,793
but we do actually style the li elements.
252
00:14:19,530 --> 00:14:24,523
And so again, let's set the font family to something,
253
00:14:25,440 --> 00:14:27,833
so to sans serif, actually.
254
00:14:29,560 --> 00:14:31,010
Give it a save.
255
00:14:31,010 --> 00:14:35,140
And we also want to change the font size one more time.
256
00:14:35,140 --> 00:14:38,640
So by default, we get this font size that we see here,
257
00:14:38,640 --> 00:14:41,883
which is usually 16 pixels by default.
258
00:14:43,140 --> 00:14:44,570
So that's an important thing
259
00:14:44,570 --> 00:14:47,270
that we also need to know a little bit later.
260
00:14:47,270 --> 00:14:49,493
So take note of that.
261
00:14:51,250 --> 00:14:54,290
But of course, we want to make it a little bit bigger.
262
00:14:54,290 --> 00:14:58,780
So we have our paragraphs at 22 pixels.
263
00:14:58,780 --> 00:15:02,050
So let's actually make this a little bit smaller.
264
00:15:02,050 --> 00:15:04,863
So let's say, at 20 pixels.
265
00:15:07,360 --> 00:15:10,540
And that's it. Beautiful.
266
00:15:10,540 --> 00:15:15,540
So we finished the basic styling of our text of our page,
267
00:15:16,000 --> 00:15:20,690
and we learned about six new CSS properties along the way.
268
00:15:20,690 --> 00:15:23,910
So take some time to review what we just did,
269
00:15:23,910 --> 00:15:26,490
and then let's move on to the next lecture
270
00:15:26,490 --> 00:15:29,543
where we will learn a little bit more about selectors.
20140
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.