Breaking News

header ads

how websites work, this is the secret no one tells

I want to talk about:  

How exactly do websites work?
What exactly do HTML, CSS, and JavaScript do exactly?
Website structure

Now, in order to access a web page, we all know that you need a browser, right? And that can be Chrome, Safari, Firefox - whatever is your favorite one.
These are all pieces of software that allow you to look up the IP address of your website and be able to receive data that it can render into these beautiful websites that we see. Now, the data that you receive from the server usually consists of three types of files:

             HTML
             CSS
             JavaScript.

And it's very likely that you would have come across these types of files or these words before because they're so common and they're so integral to how websites work. But what exactly do they do and why are there so many different types of files?
Why can't we just have one file that's, you know, a website? 
Well, they actually have very different jobs.

HTML

HTML 5
The HTML code file is responsible for the structure of your web site. So, if a website was a house, then the HTML would be the builder who would come in to build the walls or put in a toilet. Basically, HTML establishes the structure of your house and when you write code in  HTML, you also build up your website structure. 
You can use HTML to add an image or button or table or text box - whatever it is that you need on your website.

CSS
CSS 3

Now the second type of file is CSS files. And these files are responsible for styling your website. So, if you are building a house, then this would be the painters and decorators. They would be going around painting the walls or adding stylistic flourishes to your place and generally making the place look the way that you want it to. And that's exactly what CSS code does as well. When you incorporate CSS, it allows you to specify how you want your website to look. 
So you could say that "Yes, I have a button that I got from my HTML, but that button, I want it to 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 using CSS code.

Javascript
Javascript

Now the final component is the Javascript code. And this is the code that allows your website to actually do things or have behavior. And if you were building a house you would have the electrician come in, who would be able to connect the wires so that your lightbulbs actually switch on. Or somebody who comes in and does the plumbing so that your toilet can actually flush. And the Javascript code does exactly that. It allows your website to actually do things and have behavior.
So, for example, that button I added earlier on with my HTML code - only when I have the Javascript code can I actually make it do something interesting like send off an email. 

So if we take the Google website as an example. Once we receive files from the Google server when our browser loads up the HTML files, we'll get to see the structure of the website. Namely, there's one image that has their logo. There are two buttons. And there's a text box where we can enter our search. Now when we receive the CSS files, then that will modify the appearance of all of those components. We don't have any more buttons or any more images, but they now look the way that Google wanted it to. And finally when we incorporate the Javascript files, then our website actually starts having behavior. It has functionality and it's actually able to do something rather than just display some images and text to us. Now, with the knowledge that we've already acquired, we can already start messing around with websites on the Internet.
So open up chrome and head over to tech-wiki.com.
And if you're not familiar with it, it's basically, a technology news website where I get my latest tech news. Now, once you're over here, I want you to right-click on the title here and click on "Inspect". Now, this brings up the Chrome developer tools. And we're going to be exploring this in a lot more detail. But for now, we're going to use it to do something really simple. You can see that when I right-click on that heading and click "Inspect", it automatically opens up the entire code file that was used to render this website. So these are all of the elements that make up this website. And when you click on "Inspect", it will highlight to you the part of the code that corresponds to the thing that you right-clicked, right? In this case, it's this title. And inside this title, you can see that there is a link, which means that when you click on it. It'll go to another web page, but it's also got a bit of text. So right inside Chrome developer tools, if you double click on the bit of text that corresponds to the title, you can actually edit it. So let's go ahead and change the front page of Tech Crunch. Let's say something like ... So this is a great way of pranking your friends. Especially when they can see that you're on tech-wiki.com
And the title, of any of the text on the website, is what you wanted to say. And this is a great joke to play on friends who are maybe not quite as technologically advanced as you because they haven't read the article that you have. Now, unfortunately, when you hit refresh on this website, all of your good work is gone. And the reason is that when you are editing it here, inside your browser, you actually change the local copy of this file that you got back from the Google servers. But when you click refresh, then that makes a new request to the Google servers to load up a fresh copy of the website. So, of course, then it updates to the original content. But in the coming lessons, we're going to be working

Post a Comment

0 Comments