Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,560 --> 00:00:03,640
One of the most important messages
2
00:00:03,640 --> 00:00:06,470
that I want to get across in this course
3
00:00:06,470 --> 00:00:08,720
is that you do not have to memorize
4
00:00:08,720 --> 00:00:11,970
every single CSS property that there is,
5
00:00:11,970 --> 00:00:14,110
or that you learn in this course.
6
00:00:14,110 --> 00:00:18,610
And also that you can actually start writing your own CSS,
7
00:00:18,610 --> 00:00:21,570
even when you don't know everything yet.
8
00:00:21,570 --> 00:00:23,480
So for beginners, like you,
9
00:00:23,480 --> 00:00:26,550
it's really important to be aware of the fact
10
00:00:26,550 --> 00:00:29,410
that it is okay not to know everything
11
00:00:29,410 --> 00:00:31,150
and that you can always Google
12
00:00:31,150 --> 00:00:32,900
when you don't know anything
13
00:00:32,900 --> 00:00:35,160
or read the documentation.
14
00:00:35,160 --> 00:00:36,560
And so in this lecture,
15
00:00:36,560 --> 00:00:38,670
I want to quickly show you some techniques
16
00:00:38,670 --> 00:00:42,150
that I use to Google stuff that I don't know,
17
00:00:42,150 --> 00:00:44,081
and also how to read documentation
18
00:00:44,081 --> 00:00:46,970
in order to learn something about a property
19
00:00:46,970 --> 00:00:48,700
that you don't know yet,
20
00:00:48,700 --> 00:00:51,453
or that you don't remember how exactly to use.
21
00:00:52,930 --> 00:00:55,230
And let's start with a hypothetical,
22
00:00:55,230 --> 00:00:57,490
but real world scenario.
23
00:00:57,490 --> 00:01:01,500
So let's imagine that you built a forum on your webpage
24
00:01:01,500 --> 00:01:03,770
and that forum has a button,
25
00:01:03,770 --> 00:01:07,300
but now you don't remember how you can actually add
26
00:01:07,300 --> 00:01:10,180
like that mouse cursor to the button.
27
00:01:10,180 --> 00:01:12,370
So when your users hover the button,
28
00:01:12,370 --> 00:01:15,390
you want it to look something like this.
29
00:01:15,390 --> 00:01:17,410
So with this cursor here happening,
30
00:01:17,410 --> 00:01:18,410
but again,
31
00:01:18,410 --> 00:01:20,700
you don't remember how to do that.
32
00:01:20,700 --> 00:01:21,560
But again,
33
00:01:21,560 --> 00:01:25,060
you might not remember how to actually do that.
34
00:01:25,060 --> 00:01:28,440
And this is really no problem at all.
35
00:01:28,440 --> 00:01:30,430
So you can always Google something
36
00:01:30,430 --> 00:01:32,510
if you don't know how to do it
37
00:01:32,510 --> 00:01:35,520
and read the documentation as well.
38
00:01:35,520 --> 00:01:38,710
So in this case, this is what I would do.
39
00:01:38,710 --> 00:01:41,247
So I would Google CSS,
40
00:01:41,247 --> 00:01:44,240
and so the first word that I always use
41
00:01:44,240 --> 00:01:46,907
when I'm searching something related to CSS is CSS.
42
00:01:49,562 --> 00:01:50,860
And then let's say,
43
00:01:50,860 --> 00:01:55,260
CSS property to add
44
00:01:56,510 --> 00:02:01,510
a mouse cursor to button.
45
00:02:02,060 --> 00:02:05,910
So this is basically what you want to achieve, right?
46
00:02:05,910 --> 00:02:07,870
And then in the search results,
47
00:02:07,870 --> 00:02:12,870
usually you want to look for stackoverflow.com.
48
00:02:12,970 --> 00:02:16,060
So stackoverflow is basically a website
49
00:02:16,060 --> 00:02:19,640
where millions of users have posted tens
50
00:02:19,640 --> 00:02:22,620
or maybe hundreds of millions of questions
51
00:02:22,620 --> 00:02:24,850
about all kinds of programming.
52
00:02:24,850 --> 00:02:26,483
And that includes CSS.
53
00:02:27,450 --> 00:02:31,520
So this W3schools is usually not a good reference.
54
00:02:31,520 --> 00:02:33,460
So don't use that.
55
00:02:33,460 --> 00:02:37,820
Then there's also CSS-Tricks, which is also very good.
56
00:02:37,820 --> 00:02:42,350
And down here there is developer.mozilla.org,
57
00:02:42,350 --> 00:02:45,440
which is actually the MDN documentation,
58
00:02:45,440 --> 00:02:48,740
which we will check out also in a minute.
59
00:02:48,740 --> 00:02:52,250
But for now I'm interested in here is stackoverflow,
60
00:02:52,250 --> 00:02:54,930
which again is like a Q&A site
61
00:02:54,930 --> 00:02:57,080
where people can ask questions
62
00:02:57,080 --> 00:02:59,510
and then other users help them.
63
00:02:59,510 --> 00:03:00,787
So here we have a question,
64
00:03:00,787 --> 00:03:03,630
"How to change the cursor into a hand
65
00:03:03,630 --> 00:03:07,540
when a user hovers over a list item?"
66
00:03:07,540 --> 00:03:10,800
Now you are not really interested in the list item,
67
00:03:10,800 --> 00:03:12,490
but the rest of the question
68
00:03:12,490 --> 00:03:16,180
is kind of what you're looking for, right?
69
00:03:16,180 --> 00:03:20,470
So let's try to take a look at our responses here.
70
00:03:20,470 --> 00:03:22,440
And here is the most popular one
71
00:03:22,440 --> 00:03:26,763
and which was also voted as correct by the original poster.
72
00:03:27,670 --> 00:03:32,670
So here what to do is to basically add cursor set to pointer
73
00:03:32,770 --> 00:03:37,380
to the element, which should get that hand, right?
74
00:03:37,380 --> 00:03:40,890
And in fact that is actually the solution.
75
00:03:40,890 --> 00:03:43,290
So now we can just copy the solution
76
00:03:43,290 --> 00:03:46,460
or if you think that is a bad practice,
77
00:03:46,460 --> 00:03:48,510
well, then you can just go to your button
78
00:03:48,510 --> 00:03:50,460
and write it manually.
79
00:03:50,460 --> 00:03:53,260
But what matters is that now you solved your problem
80
00:03:53,260 --> 00:03:57,060
simply by Googling it now, right?
81
00:03:57,060 --> 00:03:59,950
So again, don't feel bad for having to Google
82
00:03:59,950 --> 00:04:01,400
when you don't know anything.
83
00:04:01,400 --> 00:04:03,810
I do that every single day.
84
00:04:03,810 --> 00:04:07,670
So really developers never know everything.
85
00:04:07,670 --> 00:04:09,880
We just know that something exists
86
00:04:09,880 --> 00:04:13,140
and we also know how to then look it up.
87
00:04:13,140 --> 00:04:15,620
So of course you need to know the fundamentals
88
00:04:15,620 --> 00:04:18,210
about how CSS actually works.
89
00:04:18,210 --> 00:04:22,170
But again, you don't need to memorize every single property.
90
00:04:22,170 --> 00:04:23,350
You just need to know
91
00:04:23,350 --> 00:04:27,390
that it is possible to add a mouse cursor to a button,
92
00:04:27,390 --> 00:04:31,510
but you don't have to always know how exactly to do that.
93
00:04:31,510 --> 00:04:32,347
Okay.
94
00:04:32,347 --> 00:04:35,273
And now let's try another example.
95
00:04:36,110 --> 00:04:38,930
And returning actually here to our page,
96
00:04:38,930 --> 00:04:43,390
let's imagine that we wanted to center all of these links
97
00:04:43,390 --> 00:04:45,363
inside of the navigation.
98
00:04:46,490 --> 00:04:50,270
So here we have the navigation and here we have these links
99
00:04:50,270 --> 00:04:52,610
and so we want to center them.
100
00:04:52,610 --> 00:04:55,030
So let's try to do that on our own.
101
00:04:55,030 --> 00:04:57,600
And the first approach might be to select
102
00:04:57,600 --> 00:04:59,370
these anchor elements
103
00:04:59,370 --> 00:05:03,823
and set the text-align to center, right?
104
00:05:04,960 --> 00:05:08,360
So I'm pretty sure we selected them somewhere
105
00:05:08,360 --> 00:05:10,813
and here they are actually.
106
00:05:11,790 --> 00:05:15,280
And so let's do what I just explained.
107
00:05:15,280 --> 00:05:20,280
So let's try text-align and set to center.
108
00:05:21,640 --> 00:05:22,723
Let's give it a save.
109
00:05:23,820 --> 00:05:25,563
Maybe I have to reload manually.
110
00:05:26,440 --> 00:05:27,310
Okay.
111
00:05:27,310 --> 00:05:29,763
But now you see that nothing changed.
112
00:05:30,750 --> 00:05:32,523
So let's inspect this.
113
00:05:34,250 --> 00:05:38,713
And we'll need some more space here.
114
00:05:39,740 --> 00:05:41,690
All right.
115
00:05:41,690 --> 00:05:44,470
And so selecting them,
116
00:05:44,470 --> 00:05:48,520
of course we can see the text-align, center is indeed set,
117
00:05:48,520 --> 00:05:50,223
but still nothing happens.
118
00:05:51,250 --> 00:05:52,820
All right.
119
00:05:52,820 --> 00:05:54,960
However, if we think about this,
120
00:05:54,960 --> 00:05:56,740
this actually makes sense
121
00:05:56,740 --> 00:05:58,840
because texts line does
122
00:05:58,840 --> 00:06:03,320
is to basically center some text inside of an element.
123
00:06:03,320 --> 00:06:06,330
Now these elements here are inline elements.
124
00:06:06,330 --> 00:06:09,590
And therefore the only space that they occupy
125
00:06:09,590 --> 00:06:13,590
is exactly the space that the content needs, right?
126
00:06:13,590 --> 00:06:15,600
And so the width of these elements
127
00:06:15,600 --> 00:06:20,120
is exactly as wide as it needs to be to fit the content.
128
00:06:20,120 --> 00:06:21,960
Therefore it is not possible
129
00:06:21,960 --> 00:06:24,210
to center anything inside of them
130
00:06:24,210 --> 00:06:26,770
because there's simply no empty space
131
00:06:26,770 --> 00:06:30,420
inside of which the element could be centered.
132
00:06:30,420 --> 00:06:31,300
Okay.
133
00:06:31,300 --> 00:06:34,050
So having arrived at that conclusion,
134
00:06:34,050 --> 00:06:37,480
maybe now you don't know how to actually solve the problem
135
00:06:37,480 --> 00:06:41,800
because you still want all these links centered here.
136
00:06:41,800 --> 00:06:44,990
So let's try to Google that once again.
137
00:06:44,990 --> 00:06:49,990
Let's say CSS how to center anchor elements.
138
00:06:54,650 --> 00:06:55,483
Okay.
139
00:06:55,483 --> 00:06:56,700
And now again,
140
00:06:56,700 --> 00:07:00,170
you want to be looking for stackoverflow.com
141
00:07:00,170 --> 00:07:03,500
and this one looks exactly what we are looking for.
142
00:07:03,500 --> 00:07:06,603
So how do I center an anchor element in CSS,
143
00:07:07,440 --> 00:07:08,310
and many times
144
00:07:08,310 --> 00:07:11,910
you actually need to open up various questions
145
00:07:11,910 --> 00:07:13,990
because not always their question
146
00:07:13,990 --> 00:07:15,913
is exactly the same as yours.
147
00:07:17,220 --> 00:07:18,400
Now, in this case,
148
00:07:18,400 --> 00:07:21,550
we actually have the correct solution right here.
149
00:07:21,550 --> 00:07:22,977
So what they say is,
150
00:07:22,977 --> 00:07:25,600
"Add the text- align CSS property
151
00:07:25,600 --> 00:07:28,320
to its parent style attribute."
152
00:07:28,320 --> 00:07:31,010
Well, this part of the style attribute
153
00:07:31,010 --> 00:07:32,810
is not really relevant
154
00:07:32,810 --> 00:07:36,900
because remember, I told you not to use style like this.
155
00:07:36,900 --> 00:07:37,733
Right.
156
00:07:37,733 --> 00:07:40,200
But instead using a class,
157
00:07:40,200 --> 00:07:42,660
and that is also not really important.
158
00:07:42,660 --> 00:07:46,020
What matters is that what we need is this.
159
00:07:46,020 --> 00:07:50,083
So we need text-align center set to the parent.
160
00:07:51,090 --> 00:07:52,600
All right.
161
00:07:52,600 --> 00:07:55,950
So let's then put that into our code.
162
00:07:55,950 --> 00:07:59,563
And so we want this not here,
163
00:08:00,880 --> 00:08:02,890
but we want it in the NAV.
164
00:08:02,890 --> 00:08:04,653
So let's go look for the NAV.
165
00:08:05,950 --> 00:08:07,903
It should be somewhere at the top.
166
00:08:09,460 --> 00:08:10,810
Here it is.
167
00:08:10,810 --> 00:08:15,810
And now text-align set to center.
168
00:08:16,210 --> 00:08:17,773
And here we go.
169
00:08:19,030 --> 00:08:21,670
So now these elements are actually centered
170
00:08:21,670 --> 00:08:24,620
inside of the parent container.
171
00:08:24,620 --> 00:08:25,620
Okay.
172
00:08:25,620 --> 00:08:27,300
And in this case, this works
173
00:08:27,300 --> 00:08:31,240
because these elements are inline elements
174
00:08:31,240 --> 00:08:33,910
or actually in this case, inline-blocks.
175
00:08:33,910 --> 00:08:36,520
But what matters is they do not occupy
176
00:08:36,520 --> 00:08:39,480
the entire width of the parent.
177
00:08:39,480 --> 00:08:43,620
And so when we want to center a bunch of elements like this,
178
00:08:43,620 --> 00:08:46,640
no matter if inline or inline-block elements,
179
00:08:46,640 --> 00:08:48,100
then all we need to do
180
00:08:48,100 --> 00:08:51,300
is to add the text-align center property
181
00:08:51,300 --> 00:08:53,310
on the parent element.
182
00:08:53,310 --> 00:08:54,580
Okay.
183
00:08:54,580 --> 00:08:57,504
Now maybe you wanted to learn a little bit more
184
00:08:57,504 --> 00:08:59,243
about this property.
185
00:09:01,647 --> 00:09:05,150
And so let's now use the MDN documentation.
186
00:09:05,150 --> 00:09:07,960
Now this is not an official documentation,
187
00:09:07,960 --> 00:09:10,500
but it's still what most developers use
188
00:09:10,500 --> 00:09:12,810
to look up CSS properties.
189
00:09:12,810 --> 00:09:17,000
So we write MDN then CSS,
190
00:09:17,000 --> 00:09:20,530
because on MDN, there are many different languages.
191
00:09:20,530 --> 00:09:23,683
And then let's say text-align.
192
00:09:25,552 --> 00:09:26,385
And then here,
193
00:09:26,385 --> 00:09:28,750
the first result is already what we're looking for.
194
00:09:28,750 --> 00:09:31,593
So developer.mozilla.org.
195
00:09:32,620 --> 00:09:35,960
And so here, there is basically a description
196
00:09:35,960 --> 00:09:38,630
and also some demos about different values
197
00:09:38,630 --> 00:09:39,783
for this property.
198
00:09:40,860 --> 00:09:43,340
So the text-align CSS property
199
00:09:43,340 --> 00:09:45,900
sets the horizontal alignment of the content
200
00:09:45,900 --> 00:09:49,453
inside a block element or table-cell box.
201
00:09:50,970 --> 00:09:51,803
Okay.
202
00:09:51,803 --> 00:09:53,690
And so that's exactly what we did.
203
00:09:53,690 --> 00:09:55,840
So we set it here,
204
00:09:55,840 --> 00:09:59,800
text-align center on a block element, right.
205
00:09:59,800 --> 00:10:03,500
And previously we tried to set it on an inline block element
206
00:10:03,500 --> 00:10:05,870
and there it didn't do anything.
207
00:10:05,870 --> 00:10:08,020
And so we could also have gotten that
208
00:10:08,020 --> 00:10:10,650
here from the documentation.
209
00:10:10,650 --> 00:10:13,860
Then here we can click on some different demos.
210
00:10:13,860 --> 00:10:17,723
So of course left, right, center and there's even justify.
211
00:10:19,000 --> 00:10:22,290
Then here are all the different values that exist.
212
00:10:22,290 --> 00:10:25,140
And then here's a bunch of,
213
00:10:25,140 --> 00:10:28,910
even more stuff that you probably don't even need.
214
00:10:28,910 --> 00:10:33,910
So a lot of more examples, and this one is also important.
215
00:10:34,340 --> 00:10:35,560
Well, not in this case,
216
00:10:35,560 --> 00:10:38,370
but in some more modern properties.
217
00:10:38,370 --> 00:10:41,130
Here we can see the browser compatibility
218
00:10:41,130 --> 00:10:44,173
of this specific CSS property.
219
00:10:46,010 --> 00:10:48,720
So in this case, it's not that relevant,
220
00:10:48,720 --> 00:10:51,723
but sometimes you might want to check that out as well.
221
00:10:53,230 --> 00:10:54,990
NoW another one, for example,
222
00:10:54,990 --> 00:10:57,830
we can check for border
223
00:10:57,830 --> 00:11:00,330
because this one is a little bit complex.
224
00:11:00,330 --> 00:11:03,640
And so let's say you want to set a border,
225
00:11:03,640 --> 00:11:06,920
for example, a dotted one or a wavy border,
226
00:11:06,920 --> 00:11:09,523
but you don't remember exactly the syntax.
227
00:11:10,670 --> 00:11:12,260
All right.
228
00:11:12,260 --> 00:11:15,823
So here you have a couple of examples once again,
229
00:11:17,930 --> 00:11:20,430
and you can click them and check them out.
230
00:11:20,430 --> 00:11:24,310
And here you can also learn, as I mentioned before,
231
00:11:24,310 --> 00:11:27,670
that border is actually a shorthand property
232
00:11:27,670 --> 00:11:30,763
for the border width, style and color.
233
00:11:31,790 --> 00:11:35,030
And then here again, you have a bunch of examples
234
00:11:35,970 --> 00:11:40,340
and yeah, for all the properties that you want,
235
00:11:40,340 --> 00:11:44,140
you can check out the documentation to learn exactly
236
00:11:44,140 --> 00:11:47,740
what values you can give to them and how they work.
237
00:11:47,740 --> 00:11:48,573
Okay.
238
00:11:48,573 --> 00:11:50,150
And I think with this,
239
00:11:50,150 --> 00:11:52,970
I showed you enough so that you can on your own
240
00:11:52,970 --> 00:11:56,770
now try to Google some questions that you might have,
241
00:11:56,770 --> 00:12:00,090
and also read documentation about some properties
242
00:12:00,090 --> 00:12:03,440
that you might not know exactly how they work.
243
00:12:03,440 --> 00:12:06,570
And this is a really important developer skill
244
00:12:06,570 --> 00:12:10,800
that you need to learn as you start becoming a CSS
245
00:12:10,800 --> 00:12:12,963
and also HTML developer.
17506
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.