Make your first website



Make your first website

0 1


website_workshop

A slideshow about HTML, CSS and making a basic static website

On Github sap-codekitchen / website_workshop

Make your first website

Brought to you by CodeKitchen

Before we start

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.

This is a hands on workshop. Feel free to pause me any time if something is not clear.

Part 1: What is a web page?

In a nutshell, it:

  • is a set of files that your browser (Chrome/Safari/Firefox/etc) downloads and then displays on a screen
  • has a precise address that you type to the URL bar at the top of your browser
  • comes from another computer (typically a server)
  • is made out of HTML, CSS, & JavaScript (more later on these)
  • can be an interactive document (like Facebook)

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.

Part 2: What is a web page?

Big Picture:

  • one or more webpages
  • (sometimes) a bunch of different web pages
  • (sometimes) a server application that generates web pages on the fly (like Facebook), which would be called a web app

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 difference

You 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 logic

Ready to take a look at each 'ingredient'?

Part 3: HTML

(Hypertext Markup Language)

Let'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.

Wait, wait! Did you just say "HTML5"? What's that about?

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.

Enough about standards, let's cook actual HTML!

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>

tag name (or node type)

<a href=”http://dusp.mit.edu”>link to DUSP</a>

contents

this is what you see. It can hold other HTML tags as well

<a href="http://dusp.mit.edu">link to DUSP</a>

attributes

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.

Curious for more tags?

Here is an up-to-date list of all the HTML tags (tags are also sometimes called elements).

Part 4: CSS

aka Cascading Style Sheets

which cascade like waterfalls of styling rules

CSS has a simple, consistent syntax:
selector {
                  setting: value;
                }
                
Here are some common CSS selectors:

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! :)

Here is a great tutorial on CSS selectors
More on colors: you can enter colors in a number of ways
              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, rem

Part 5: Go Live

ssh into your athena account and navigate to your www folder and deploy our example site there.

Forgot how? Checkout my basic command line tutorial

Any questions?