So, now that we've spoken about how the Internet works, in this episode I want to talk about: How exactly 1
do websites work? 2
What exactly does HTML, CSS and Javascript do exactly? 3
Now, in order to access a web page, we all know that you need a browser, right? And that can be Chrome, Safari, 4
Firefox - whatever is your favorite one. 5
These are all pieces of software that allow you to look up the IP address of your website and be able 6
to receive data that it can render into these beautiful websites that we see. Now, the data that you 7
receive from the server usually consists of three types of files: 8
HTML, CSS and Javascript. 9
And it's very likely that you would have come across these types of files or these words before because 10
they're so common and they're so integral to how websites work. 11
But what exactly do they do and why are there so many different types of files? 12
Why can't we just have one file that's, you know, a website? 13
Well, they actually have very different jobs. 14
The HTML code file is responsible for the structure of your web site. 15
So if a website was a house, then the HTML would be the builder who would come in to build the walls 16
or put in a toilet. 17
Basically they establish the structure of your house and when you write HTML code, you also build up the 18
structure of your website. So you could use HTML to add an image or button or text box - whatever it 19
is that you need in your website. 20
Now the second type of files are CSS files. And these files are responsible for styling your website. 21
So, if you are building a house, then this would be the painters and decorators. They would be going around 22
painting the walls or adding stylistic flourishes to your place and generally making the place look 23
the way that you want it to. 24
And that's exactly what CSS code does as well. 25
When you incorporate CSS, it allows you to specify how you want your website to look. 26
So you could say that "Yes, I have a button that I got from my HTML, but that button, I want it to 27
be red. And I want the text to be white. And I want the font of the text to be in Aerial." That is all done 28
using CSS code. 29
Now the final component is the Javascript code. And this is the code that allows your website to actually 30
do things or have behavior. 31
And if you were building a house you would have the electrician come in, who would be able to connect 32
the wires so that your lightbulbs actually switch on. Or somebody who comes in and does the plumbing 33
so that your toilet can actually flush. And the Javascript code does exactly that. 34
It allows your website to actually do things and have behavior. 35
So, for example, that button I added earlier on with my HTML code - only when I have the Javascript 36
code can I actually make it do something interesting like send off an email. 37
So if we take the Google website as an example again. Once we receive these files from Google server 38
when our browser loads up the HTML files, we'll get to see the structure of the website. 39
Namely there's one image which has their logo. 40
There's two buttons. And there's a text box where we can enter our search. 41
Now when we receive the CSS files, then that will modify the appearance of all of those components. 42
We don't have any more buttons or any more images, but they now look the way that Google wanted it to. 43
And finally when we incorporate the Javascript files, then our website actually starts having behavior. 44
It has functionality and it's actually able to do something rather than just display some images and text 45
to us. 46
Now, with the knowledge that we've already acquired, we can already start messing around with websites 47
on the Internet. 48
So open up chrome and head over to techcrunch.com. 49
And if you're not familiar with it, it's basically a technology news website where I get my latest tech 50
news. 51
Now, once you're over here, I want you to right-click on the title here and click on "Inspect". 52
Now, this brings up the Chrome developer tools. And we're going to be exploring this in a lot more detail. 53
But for now, we're going to use it to do something really simple. 54
You can see that when I right-click on that heading and click "Inspect", it automatically opens up the 55
entire code file that was used to render this website. 56
So these are all of the elements that make up this website. 57
And when you click on "Inspect", it will highlight to you the part of the code that corresponds to the 58
thing that you right-clicked, right? 59
In this case it's this title. 60
And inside this title, you can see that there is a link, which means that when you click on it. 61
It'll go to another web page, but it's also got a bit of text. 62
So right inside Chrome developer tools, if you double click on the bit of text that corresponds to the 63
title, you can actually edit it. 64
So let's go ahead and change the front page of Tech Crunch. 65
Let's say something like ... 66
So this is a great way of pranking your friends. Especially when they can see that you're on 67
techcrunch.com 68
And the title, of any of the text on the website, is what you wanted to say. And this is a great joke 69
to play on friends who are maybe not quite as technologically advanced as you because they haven't taken 70
the course that you have. Now unfortunately 71
when I hit refresh on this website, all of my good work is gone. 72
And the reason is because when I'm editing it here, inside my browser, I'm actually changing the local 73
copy of this file that I got back from the Google servers. But when I click refresh, then that makes a 74
new request to the Google servers to load up a fresh copy of the website. 75
So, of course, then it updates to the original content. But in the coming lessons, we're going to be working 76
with HTML, CSS and Javascript so that you can create and host - live on the internet - your very own web 77
sites. And through learning how to code and how to build websites, you're going to be able to make websites 78
that say anything that you want it to, look the way that you want it to, and have the functionality that 79
you need. 80
So all of that and more, 81
I'll see you on the next lesson.