A short taster session into the fundamental technologies powering the world wide web.
In this session we will take our first step towards creating Ben's website. Together, by the end of the session we will have created this.
Although it may not look like much, getting the bare bones of the site created quickly will speed up development down the road.
Every website on the Internet is just a set of files that your browser (Chrome in this case) knows how to display. These three file types are:
All of these technologies are said to be client side technologies, this means that HTML, CSS and JavaScript runs on your computer.
When you visit a website what you are actually doing is requesting the HTML, CSS and JavaScript files from a web server that hosts that sites files. Your browser then reads these files and displays them to you as a web page.
This has an interesting side effect that we will discover now.
Because the HTML, CSS and JavaScript 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 for you to look at the source of the site your are currently browsing, and Chrome's is especially good.
Google Chrome comes with a powerful set of developer tools built in that allow you to interactively inspect the source code of a site that you visit. To open developer tools use View > Developer > Developer Tools
View > Developer > Developer Tools
One of the great things about HTML is that you don't need a lot to see it working on your laptop, all you need is a text editor and a web browser.
To get up and running you need to understand that a website is just a collection of files that all live inside one folder. This folder effectivly becomes your website. When we want to put our website on the Internet, all we need to do is move this folder to a web server somewhere.
Anything that you want to appear on your website must be within this folder. HTML, CSS, JavaScript, Images & Downloadable Content, it all must go inside this folder
All HTML that we will ever write needs to be written in a text editor. Remember from the prep work that we use Sublime as it doesn't save any extra nasty characters like Word does and it gives us Syntax highlighting, this will make more sense later!
Ok - let's write our first bit of HTML, remember the site we are trying to create in this session is here.
Let's take our first step towards that by creating a heading element on our site.
<h1> My Little Coding Shop </h1>
File > Open File
Then navigate to the folder and file you just createdAll html files must have the .html extension. This tells the computer that this is a HTML file.
The default name for a HTML file is index.html This means that unless you ask for another file specifically, you will be given the index.html file
This is really important as it means that the homepage of every website is called index.html. Try it out!
There are loads of HTML tags that you can use to define the structure of your page, and they all follow a similar format to the heading above.
<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.
<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">
<button>this is a my button text</button>
<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.<blockquote>Some inspirational quote here</blockquote>
The blockquote tag specifies a section of text that is quoted from another source. It's very similar to a traditional paragraph tag but it is more semantic.
Using the tags above we're now going to complete this sessions exercise. We'll get our site to look just like our target site.
<h1>
tag add a <p>
tag. Add some text inside it and close it with a </p>
</p>
tag add a <button>Shop now</button>
set of tags <ul>...</ul>
pair of tags<ul>
and </ul>
tags add a <li>...</li>
tag<img>
tag add the first image of a product to your site. Hint, the code you'll need will look similar to <img src="style.jpg">
Where alice.jpg must match the exact filename of the image that you downloaded<img>
tags add <p>...</p>
tags<p>
and </p>
tags paste the contents of the product descriptions<a href="#">..</a>
set of tags. Place the text including the price inside each.If you get stuck, look at the solution and use Chrome's developer tools to help you out.
There's one last thing we need to fix, our bullet point list should be links, but at the moment they're plain text. We can nest as many tags inside each other as we like, so to create nested links within a bullet point you can use the following code:
<ul> <li> <a href="#">Text here</a> </li> </ul>
One last thing - this isn't valid HTML yet. All HTML documents must follow a strict pattern to be considered HTML. That pattern is:
<!DOCTYPE html>
<html>
<head>
<title>Page title</title>
</head>
<body>
...
</body>
</html>
This is commonly called HTML boilerplate or skeleton code.
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<html>
tag. On the last line add the closing </html>
tag<html>
tag add the <head>
and </head>
tags</head>
tag add the <body>
tag and add the closing </body>
tag above the </html>
tag at the bottom of the file