A webpage is just a set of files that your web browser knows how to display.
There are three possibilities for the types of files they could be: HTML, CSS and Javascript. Most web pages will be a mixture of all three. Because the files have to be able to be interpreted by all web browsers on all operating systems, the choices are limited and don’t change very often.
HyperText Markup Language encodes the information that is sent back from the server.
Cascading Style Sheets tell your browser how to display that information.
Javascript is a programming language that can be used to provide client-side interactivity.
HTML, CSS and Javascript are known as client-side technologies, because they are sent to your web browser (the client).
HTML (HyperText Markup Language) is a way of writing information so that it can be interpreted by a web browser. It is not a programming language - you can’t do calculations in it - it is a markup language. CSS is also a markup language. Javascript is a programming language.
Back in the early days of the web HTML would both store the information and tell the browser how to display it. People then realised that this was a bad idea - making a small change such as changing the colour of a heading would require edits all over the place, which made sites hard to maintain. HTML is now used just to display the information (text etc.) that is stored in the page. CSS is used to tell the browser how to display the information.
Because the HTML, CSS and js are sent you your browser, it is easy for you to look at them. There are no secrets in HTML, CSS or js. If there’s a part of a webpage that you like, it’s easy to find out how it is coded and use the technique yourself.
Every browser provides a way to look at the source of the page you’re currently viewing. In Chrome you do View > Developer > View Source
. This will show you the raw HTML but isn’t always the easiest thing to look at.
Several browsers also provide developer tools, which allow you to interactively view the page source. In Chrome you can access these by doing View > Developer > Developer Tools
. If you use Firefox, you can get similar functionality with the Firebug plugin. These tools are the best way to investigate a web page. Over the course you will be using them a lot on your own pages, especially when things aren’t working exactly as you expect.
There are a few features of the Chrome developer tools that it is worth pointing out now.
Resources
tab. See if you can find the CSS, javascript and image files used on this page.You can think of the internet as a massive network of computers that can send files to one another. The computers that hold web pages are called servers. Servers are large, specialised computers that are permanently connected to the internet.
Once the address of the web server has been found your request is forwarded on to it, the web server will interpret your request and send back one or more files. We now look at the technology involved in this process.
There are two main possibilities server-side: either your site is static or dynamic.
Most of the sites you can think of will be dynamic sites (e.g. [facebook.com], [reddit.com], [amazon.com], ..).
There are many options for building a dynamic server-side site - you’re pretty much free to do what you like. Some common choices are:
A web development framework written in the Ruby programming language.
A programming language that formed the basis of most dynamic websites in the early 2000s.
A web development framework written in the Python programming language.
A web development framework written in javascript.
A blogging platform (now capable of much more) written in php.
Many of our web interactions begin with a URL (uniform resource locator) being typed into our web browser address bar. Let’s look at an example: http://www.bbc.co.uk/news/
.
This URL has several different parts to it:
http
: the protocol or how to fetch the informationwww.bbc.co.uk
: the host or where to fetch it from/news
: the path or precisely what information to fetchWhen we type the URL into the address bar a request is sent over the internet and some information is returned to us.
The protocol describes how the information is transmitted. Other possibilities include https
for secured communication, ftp
for file transfer and git
which we’ll learn about later.
The host describes where the information should come from and the path tells that location precisely what information to send.
In general a URL can be more complicated than this. URLs can also contain query parameters, fragments and port information. We will leave these for now but will point them out when we meet them later. Instead we will focus on exactly what information is being sent and who is sending it.
Each computer on the internet has an address (an IP address) so that requests can be sent to it and files returned - much like a telephone number. The backbone of the internet is a network of routers that are responsible for routing files from one IP address to another.
IP addresses are a sequence of numbers and ‘.’s such as 212.58.244.67
. These aren’t very easy to remember. Instead the internet works on a domain name system, that matches domain names such as bbc.co.uk
to IP addresses.
Type 212.58.244.67
into your browser's address bar. What happens?
One of the first things that happens when you type a URL into your browser is a DNS lookup: your computer contacts a DNS server (Domain Name System server), which is basically a massive address book of IP addresses. The DNS server converts the domain name from the URL (e.g. bbc.co.uk
) into an address for a server (such as 212.57.244.67
).
If you want to put up your own website at your own domain name you need two things:
There are many options for web servers - you don’t have to physically have your own one. There are many companies that will offer web hosting, often providing you with space on a shared server. Later in the course we will use the free hosting offered by GitHub through GitHub Pages.
To buy a domain name you need to use a domain registrar. Examples include 123-reg.co.uk, godaddy.com and namecheap.com. You pay the registrar to contact the body who manages a TLD (e.g. .com, .org., .co.uk) and put your server’s IP address in their DNS address book. If someone else already owns the domain you might be able to buy it off them, but this can be expensive!
Many domain registrars will try to sell you hosting and other site building tools when you buy a domain. It’s important to remember that the domain name is completely separate from the hosting and you don’t need to do them both through the same company - don’t buy anything you’re not going to use.
One of the nice things about HTML is you don’t need a lot to test it out on your laptop: all you need is a text editor and a web browser.
coding_course
folder create another folder called first_site
.index.html
in the first_site
folderindex.html
in Chrome. Depending on your version of Chrome
In the old days of the web, navigating a website was a lot more like moving around the folder system on your laptop. You’d go to a base site and there would just be a list of the files and folders available: an index. Because of this index.html
is still the default file that a server will serve when you navigate to a folder in the web browser.
<h1>Hello</h1>
This is your first real html tag. It has an open and a close. It tells it to be a heading.
coding_course
folder (by clicking 'Clone in Desktop' in the bottom right).example.html
in Chrome and look around with the developer toolsnotes.html
in Sublime Text.notes.html
into valid html so that it looks like notes_solution.jpg
A few things to look out for
<!DOCTYPE html>
<html>
<head>
<title>Page title</title>
</head>
<body>
...
</body>
</html>
html
.<html> ... </html>
tag<body> ... </body>
tags are displayed on the page<head> .. </head>
are used to provide more information about the page<title> ... </title>
will be displayed in the browser bar<h1>Top level heading</h1>
<h3>Lower level heading</h3>
h1
.. h6
h1
on a pageh4
in real pages<p>This is a paragraph.</p>
<p>This is another paragraph. It has some <em>italic text</em> and some <strong>bold text</strong>.</p>
<p>
tag<em>
tag is used to provide emphasis. In reality that means italics - in fact the tag <i>
also works. Using em is better though as it fits with the idea of semantic markup - marking your information as to its meaning, instead of how you want it to look.<strong>
tag is used to make text stand out. It basically means bold - <b>
also works, but <strong>
is better - see above.<!-- comments look like this -->
<ul>
<li>Apples</li>
<li>Oranges</li>
</ul>
<ul>
is for an unordered list. This means bullet points.<ol>
is for an ordered list. That means automatic numbering.<li>
tag. This stands for list item.<a href="http://www.facebook.com">this is a link to facebook</a>
href
property tells you where the link will pointwww.example.com
the link will point to www.example.com/about
about
in the same folder as your current html file.href="#my_tag"
. This<a href="http://www.facebook.com" target="_blank">
<img alt='my cat' src="my_cat.png">
alt
tag is for providing a description of your image. This is useful for partially sighted people using screen readers, or in case the image doesn’t load.my_cat.png
in the same folder as the html file.<table>
<thead>
<tr>
<th>Column1 Heading</th>
<th>Column2 Heading</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row1, Column1</td>
<td>Row1, Column2</td>
</tr>
<tr>
<td>Row2, Column1</td>
<td>Row2, Column2</td>
</tr>
<tr>
<td>Row3, Column1</td>
<td>Row3, Column2</td>
</tr>
</tbody>
</table>
Finish the HTML exercise from the last section.
Your domain name will be used to point towards your personal website for the course - it’s up to you exactly what this will be about. You might want to use this opportunity to create a basic ‘personal landing page’ saying a bit about yourself and where to find more information. Or you might want to put up a blog. Alternatively if you want you can put up a page about something you are interested in (or your dog). You will need to pick a domain name accordingly!
To buy a domain name you need to visit a domain registrar. Examples are:
There probably won’t be a huge difference in price between these sites. You might be able to find a special offer on one of them if you shop around a bit though. Ultimately the domain you choose isn’t that important for the course - the whole point is to practice pointing a domain name towards a server.
Buy your own domain name.
Use what you've learnt from the HTML exercise and the Dash projects to improve your first_site/index.html
. Maybe add some content about yourself. Don't worry if it doesn't look great yet - we'll be working on it more in the next few weeks. Just make sure it says something more than 'Hello'!