Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,260 --> 00:00:05,570
Hey guys, welcome to another lesson where we learn more about CSS.
2
00:00:05,689 --> 00:00:12,950
Now in this lesson, we're going to deep dive into "CSS Inspection" and learn about the Chrome Developer
3
00:00:12,950 --> 00:00:20,300
Tools that allow us to figure out what our CSS is doing and potentially diagnose any bugs or resolve
4
00:00:20,300 --> 00:00:21,320
any issues.
5
00:00:22,550 --> 00:00:28,220
As I mentioned before, the Chrome Developer Tools are a really powerful suite of tools that is completely
6
00:00:28,220 --> 00:00:31,800
free and comes bundled with the Chrome browser.
7
00:00:31,820 --> 00:00:35,570
If you are not using a Chrome browser, you won't get access to it.
8
00:00:35,570 --> 00:00:41,780
And it's really important, at least for this course, that you've got the same browser as I'm using
9
00:00:41,780 --> 00:00:44,090
so that we can go through these tools together.
10
00:00:44,360 --> 00:00:50,960
If you head over to this URL, which we visited before, in the last section where I showed you how CSS
11
00:00:50,990 --> 00:00:57,920
works and how we can simply add CSS to make our website look beautiful, then we can use this as an
12
00:00:57,920 --> 00:01:01,160
example to learn more about CSS inspection.
13
00:01:01,430 --> 00:01:07,460
In order to bring up the Chrome developer tools, we go over to these three dots and then we go to more
14
00:01:07,460 --> 00:01:10,160
tools and we go to developer tools.
15
00:01:10,400 --> 00:01:19,310
Now you'll notice that on the right-hand side of this selection, you have the shortcut for your computer
16
00:01:19,340 --> 00:01:21,980
on how you can bring it up quickly.
17
00:01:21,980 --> 00:01:22,810
On a Mac.
18
00:01:22,820 --> 00:01:32,780
It's usually set by default to Command, Option and I, on Windows it's normally Ctrl + Shift +
19
00:01:32,780 --> 00:01:33,050
I.
20
00:01:33,080 --> 00:01:35,810
So holding down those three keys together.
21
00:01:35,990 --> 00:01:41,840
But if you have the function keys up here, pressing F12 usually also brings up the Chrome Developer
22
00:01:41,840 --> 00:01:42,650
console.
23
00:01:42,650 --> 00:01:44,900
But the shortcut could be totally different for you.
24
00:01:44,900 --> 00:01:49,730
So make sure you take a look over here to figure out what your precise shortcut is.
25
00:01:50,030 --> 00:01:55,370
Another way of bringing up this Developer console is simply to right-click on any element you're interested
26
00:01:55,370 --> 00:01:55,730
in,
27
00:01:55,730 --> 00:02:00,740
for example, this button and then click on inspect and it will do the same thing.
28
00:02:00,740 --> 00:02:06,200
But in addition, it will highlight in the HTML that element that you selected.
29
00:02:06,230 --> 00:02:10,370
Now what if you wanted to select a different element while you're here?
30
00:02:10,400 --> 00:02:17,210
Well, you can use this button up here to select an element visually so you can click that and then
31
00:02:17,240 --> 00:02:22,500
say, okay, I want to look at the footer here, this paragraph, Well, then it will select it for
32
00:02:22,500 --> 00:02:23,450
you in the HTML.
33
00:02:23,460 --> 00:02:30,240
Or I want to look at this h1 so you can select it visually or you can select it using the HTML.
34
00:02:30,810 --> 00:02:37,860
This is the "Elements tab" and we're going to be exploring a subsection of this, which is the "Styles
35
00:02:37,860 --> 00:02:38,700
section."
36
00:02:38,850 --> 00:02:45,570
Notice that when I select any of these elements, it shows me the styles that have been applied to those
37
00:02:45,570 --> 00:02:46,330
elements.
38
00:02:46,350 --> 00:02:52,590
For example, if we take a look at this button, at least in the CSS on version, you'll see that it's
39
00:02:52,590 --> 00:02:54,480
got a background-color that I've set.
40
00:02:54,510 --> 00:02:59,340
I've set a color for the text and lots of other things that we don't need to worry about too much right
41
00:02:59,340 --> 00:03:03,930
now because in the next lesson we're going to learn more about different CSS properties.
42
00:03:03,930 --> 00:03:09,990
But the important thing is that notice if I go ahead and press that button and switch off all the CSS
43
00:03:09,990 --> 00:03:17,250
and I select that button again, then you can see that most of the element style is actually all automatic.
44
00:03:17,250 --> 00:03:24,780
Whenever you insert a HTML element, it comes with automatic preloaded CSS and that's what you're getting
45
00:03:24,780 --> 00:03:31,200
by default, it looks something like this, but when you actually apply your own CSS, then it gets
46
00:03:31,200 --> 00:03:34,410
shown here and you can even see which file it's coming from.
47
00:03:34,410 --> 00:03:41,460
In this case, it's the styles.css right here and you can click on it to view the source code of that
48
00:03:41,460 --> 00:03:42,300
CSS.
49
00:03:43,290 --> 00:03:49,350
The next thing I want to show you is how you can actually change the CSS live in the Chrome developer
50
00:03:49,350 --> 00:03:50,070
tools.
51
00:03:50,160 --> 00:03:59,100
Right now you can see I've got my h1 selected and by simply clicking add, I can add (+) a style to this h1.
52
00:03:59,100 --> 00:04:07,710
So I could say let's change its color instead of white to maybe black instead.
53
00:04:07,710 --> 00:04:10,610
And you can see that reflected live over here.
54
00:04:10,620 --> 00:04:16,440
Now I can switch that off by hovering over here and clicking on the button to put a slash through it
55
00:04:16,440 --> 00:04:18,660
and it deletes that CSS.
56
00:04:18,690 --> 00:04:24,720
Now, the important thing to remember is any of the changes that you make in the Chrome Developer Tool
57
00:04:24,750 --> 00:04:28,020
does not affect your original file.
58
00:04:28,050 --> 00:04:35,400
Previously, remember when we looked at TechCrunch using the Chrome Developer Tools and we were able to change
59
00:04:35,400 --> 00:04:40,050
the text by simply typing in the Chrome Developer Tool.
60
00:04:40,500 --> 00:04:46,590
This does not change Techcrunch's website and some of you have asked is this illegal?
61
00:04:46,620 --> 00:04:47,760
Am I doing something bad?
62
00:04:47,790 --> 00:04:48,360
No, it doesn't.
63
00:04:48,360 --> 00:04:53,730
It's just you affecting your local copy that's loaded up inside the Chrome browser.
64
00:04:53,730 --> 00:04:59,490
It doesn't affect any of the other users and certainly doesn't change anything on Techcrunch's servers.
65
00:04:59,820 --> 00:05:07,470
Similarly, back over here, when we're editing the CSS, when we are selecting or unselecting or adding
66
00:05:07,470 --> 00:05:11,040
new rules, it doesn't affect the actual website.
67
00:05:11,370 --> 00:05:16,560
Even if you load up one of your local websites that you're developing and you change a whole bunch of
68
00:05:16,560 --> 00:05:18,390
things, this is just temporary.
69
00:05:18,390 --> 00:05:21,630
It's for you to look and try things out and
70
00:05:21,860 --> 00:05:28,130
see how you like it before you add these rules into your actual CSS source code.
71
00:05:28,130 --> 00:05:32,720
And you can further confirm this by seeing that I've got an h1 that says color black,
72
00:05:32,720 --> 00:05:39,950
but if I go into the sources, my style.css for this file and I look in this file, you can see that
73
00:05:39,950 --> 00:05:41,810
nothing has changed here.
74
00:05:42,140 --> 00:05:47,270
There is no h1 that has a color of black.
75
00:05:47,600 --> 00:05:50,840
Again, I recommend, don't worry too much about the different properties,
76
00:05:50,840 --> 00:05:53,840
there's lots of them that's coming up that we're going to talk about,
77
00:05:53,840 --> 00:05:59,780
but the main thing to focus on here is how to use the inspector to understand other peoples', as well
78
00:05:59,780 --> 00:06:03,080
as, your own websites and how the CSS is laid out.
79
00:06:03,560 --> 00:06:07,820
If you go ahead and inspect on one of these anchor tags.
80
00:06:07,820 --> 00:06:11,240
So when you click this and hover over it, you should see an "a" tag show up,
81
00:06:11,240 --> 00:06:14,390
so click on it and it'll select it in the HTML.
82
00:06:14,420 --> 00:06:20,720
Now, if you look over here, you can see that it's got some default properties that have been striked-out,
83
00:06:20,720 --> 00:06:30,150
and the reason for this is because when we apply a CSS rule that conflicts with some of the automatically
84
00:06:30,150 --> 00:06:35,820
applied rules, such as the color of that anchor tag, remember, by default, the color of any anchor
85
00:06:35,820 --> 00:06:37,710
tag is blue to start with,
86
00:06:37,740 --> 00:06:39,810
but here we've got one that's white.
87
00:06:39,840 --> 00:06:42,690
Well, we've overridden it simply with this line.
88
00:06:42,690 --> 00:06:46,170
So if I switch this off, you can see the other one switched back on.
89
00:06:46,170 --> 00:06:51,480
But if I do have my own rules, then it can override other existing rules.
90
00:06:51,480 --> 00:06:55,860
So how do you know what's actually being applied to your CSS element?
91
00:06:55,890 --> 00:07:01,230
Well, that's where the "Computed tab" comes in, because when you click on it, you'll see the actual
92
00:07:01,230 --> 00:07:03,030
color in terms of RGB.
93
00:07:03,030 --> 00:07:09,600
So how much red, green and blue is being applied to the text color and other properties as well,
94
00:07:09,600 --> 00:07:14,190
and it removes all of the craziness of all this crossing-out stuff.
95
00:07:14,190 --> 00:07:18,780
And you can actually see in one place what is being applied.
96
00:07:19,140 --> 00:07:25,620
Now another feature of Chrome Developer Tool that I find really useful is to go over to the three dots,
97
00:07:25,650 --> 00:07:33,270
go to more tools, and remember, this is the three dots for the settings of the Chrome Developer Tools,
98
00:07:33,270 --> 00:07:35,160
not the one for Chrome.
99
00:07:35,160 --> 00:07:40,830
This is easily confused, but when you go here and you go to more tools, you should find "CSS overview,"
100
00:07:40,830 --> 00:07:47,310
and this is a neat feature where you can select "Capture overview" and it will show you a bunch of useful
101
00:07:47,310 --> 00:07:51,210
things like, for example, that there are two background colors here.
102
00:07:51,210 --> 00:07:55,410
There's a sort of whitish gray and there's a sort of purple going on.
103
00:07:55,440 --> 00:07:59,160
There's two different text colors, white and black.
104
00:07:59,280 --> 00:08:04,470
And we've also got information on the different fonts that are being used on the web page.
105
00:08:05,160 --> 00:08:10,080
I find this really neat when I come across a website that I really like and I'm trying to figure out,
106
00:08:10,080 --> 00:08:11,850
oh, what font is that?
107
00:08:11,880 --> 00:08:18,120
Well, it seems like they're using Helvetica Neue, or what color is this green, exactly?
108
00:08:18,120 --> 00:08:24,330
Well, I can actually find out simply by looking at this inspector and maybe I can copy it for my own
109
00:08:24,330 --> 00:08:25,380
use later on.
110
00:08:25,380 --> 00:08:27,840
So you can see the colors, you can see the fonts.
111
00:08:27,840 --> 00:08:31,290
And for now, we won't worry too much about the last two
112
00:08:31,320 --> 00:08:34,200
we'll come to that in later modules.
113
00:08:34,530 --> 00:08:42,179
Have a play around with the CSS inspector and I want you to take a look at selecting different elements,
114
00:08:42,179 --> 00:08:48,780
looking at their styles, trying to add some styles in the Chrome Developer Tools and looking around
115
00:08:48,780 --> 00:08:51,030
at some of the other things we've mentioned.
116
00:08:51,480 --> 00:08:57,100
Once you're happy that you know how to do that, I want you to head over to this URL,
117
00:08:57,120 --> 00:09:06,030
appbrewery.github.io/css-inspection/ and I've created a website for you to inspect. In this website,
118
00:09:06,030 --> 00:09:15,870
we've got some things that are on the screen and this is an h1 and h2 and a paragraph tag.
119
00:09:15,870 --> 00:09:24,780
Now I want you to use the CSS inspector to answer these four quiz questions and once you've put in the
120
00:09:24,780 --> 00:09:28,950
answer, click submit and you'll see if you got it right or if you got it wrong.
121
00:09:29,370 --> 00:09:32,940
Pause the video and try to complete this challenge.
122
00:09:34,940 --> 00:09:35,300
All right.
123
00:09:35,300 --> 00:09:40,280
So the first question is, what is the named color of the body?
124
00:09:40,310 --> 00:09:41,810
Well, what is the color?
125
00:09:41,810 --> 00:09:48,350
So let's go ahead and pull up our inspector and let's select the body element if we haven't already
126
00:09:48,350 --> 00:09:50,330
got it selected in the HTML.
127
00:09:50,330 --> 00:09:53,380
And let's take a look at what styles are applied.
128
00:09:53,390 --> 00:09:56,810
You can see it's got a background color that's being applied.
129
00:09:56,810 --> 00:10:01,430
And if we switch it off, you can see it changes it to the default, which is white.
130
00:10:01,430 --> 00:10:05,630
So this is the background color of the body and it's called "aliceblue."
131
00:10:05,660 --> 00:10:11,720
If I type that in here and click submit, then I get my answer correct.
132
00:10:11,960 --> 00:10:14,000
Now let's move on to the second question.
133
00:10:14,000 --> 00:10:16,580
What's the font size of the h1?
134
00:10:16,580 --> 00:10:23,300
Let's select the h1 right here and let's take a look at the font size that's mentioned here.
135
00:10:23,300 --> 00:10:28,130
Well, it says it's 3rem, which makes it a lot bigger than the default.
136
00:10:28,130 --> 00:10:32,840
So let's type 3rem in here, hit submit.
137
00:10:32,840 --> 00:10:39,660
And we got that question right too. Number 3 is, what is the font weight of the h2?
138
00:10:39,690 --> 00:10:45,900
Select the h2, look at the font-weight, its font-weight 500.
139
00:10:46,170 --> 00:10:46,740
Okay.
140
00:10:46,740 --> 00:10:48,180
And hit submit.
141
00:10:48,600 --> 00:10:54,000
And finally, what's the font-family of the paragraph tag?
142
00:10:54,000 --> 00:10:59,640
So let's select the paragraph tag and then look at the font-family.
143
00:10:59,640 --> 00:11:06,240
And this is a little bit tricky because it's actually not applied directly to the paragraph, but it's
144
00:11:06,270 --> 00:11:10,680
actually one of the automatically inherited parts.
145
00:11:10,680 --> 00:11:13,710
So you can see down here it says the font-family.
146
00:11:13,710 --> 00:11:19,470
And also if you go to computed where everything's all stacked up together, as I mentioned, where you
147
00:11:19,470 --> 00:11:24,570
don't have to go through the entire list of what's being striked out, what's being applied, etcetera.
148
00:11:24,570 --> 00:11:29,310
You can see the font family is "Arial, sans-serif."
149
00:11:29,310 --> 00:11:37,560
So Arial, sans-serif. and hit submit and we get all our answers correct.
150
00:11:37,560 --> 00:11:39,360
So did you manage to do that?
151
00:11:39,360 --> 00:11:43,200
Did you manage to use the inspector to figure out the answers to these questions?
152
00:11:43,200 --> 00:11:48,870
If not, be sure to review the previous parts of this video so that you understand exactly what's going
153
00:11:48,870 --> 00:11:51,450
on before you move on to the next lesson.
16317
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.