On Github sap-codekitchen / website_workshop
Brought to you by CodeKitchen
Today we will build on the last week's workshop Secret Coding Essentials. Make sure you have Sublime Text or some other text editor installed.
In this workshop we will talk about what a website is, how to "open it" and look inside, and how to make your own.
In a nutshell, it:
These slides are a web page. http://codekitchen.mit.edu/ is also an example of a web page
Every browser gives you the ability to see the source code of the website. This is extremely useful for understanding and building websites of your own.
If you are using Google Chrome on a Mac, type Option+Command+U to look at the web page's source code.
For other OS + browsers read here.Where did these files come from? A server!
In the simplest terms, a server is just another computer. But we usually use servers for different purposes than our personal computers. Servers are usually connected to the internet, or are at least connected to a local network. They rarely have monitors or GUI software so they often accessed through the command line.
Big Picture:
Let's look at a website:
Download the folder from Dropbox and save it somewhere on your computer Open the folder with your text editor (like Sublime Text) Change few things and see the differenceYou have just seen the basic building blocks of a website. How cool :) Specifically you saw:
file with .html extension. This file structures the content of the web page file with .css extension. This is a special file that stores the styling information about the website file with .js extension. This file adds interactions and logicLet's look at the developer console. This is similar to looking at the source code, except that instead of showing the original code that was downloaded from the server, it shows us how the browser sees the website right at this moment. The console is powerful.
If you are using Google Chrome on a Mac, type Option+Command+I
HTML is not really a language, it's actually a standard, a specification published by the W3C, World Wide Web Consortium.
Browsers voluntarily adhere to the specification or not. Sometimes they only adhere to portions of it.
The W3C negotiates the specifications for the web, including HTML, CSS (.css file you saw in the example), and Javascript (.js file you saw). Browsers have to implement support for any changes to the specification.
Google Chrome, Mozilla Firefox, and Apple's Safari adhere to the vast majority of the most recent HTML specification (currently HTML5).
Microsoft's Internet Explorer is notorious for ignoring the standards set by W3C.
There is never 100% compliance. Many parts are hotly debated.
HTML5 & HTML4 are just editions of the standard. Similar to International Building Code 1999 vs IBC 2001
We are writing HTML5 because that is the most recent spec. There are very few differences. We aren't using any of the obscure features that browsers aren't ready to support.
HTML is a tree with nodes, where each node has:
opening and closing pointy brackets<a href=”http://dusp.mit.edu”>link to DUSP</a>
<a href=”http://dusp.mit.edu”>link to DUSP</a>
this is what you see. It can hold other HTML tags as well
<a href="http://dusp.mit.edu">link to DUSP</a>
in the format attributename="value"
<a href="http://dusp.mit.edu">link to DUSP</a>
There are only a small set of commonly used tags.
body div p span a header navigation ul ol li link script img em strong form input
You can memorize most of them, but you can look them up any time. They are well documented.
Here is an up-to-date list of all the HTML tags (tags are also sometimes called elements).
which cascade like waterfalls of styling rules
selector { setting: value; }
Select via tag names
img { width: 100%; }
Select using a "class" attribute
.options { list-style-type: none; }
Select using the "id" attribute
#container { width: 32rem; }
CSS can get complicated quite fast. Especially if you want a fancy layout. It is not intuitive. But colors and fonts are easy! :)
color: orange; // Color assigned by name color: #0f0; // 3 digit hex color: #00ff00; // 6 digit hex // color defined using RGB and "alpha" values color: rgba( 34, 12, 64, 0.3);
There are special units
px, em, remForgot how? Checkout my basic command line tutorial