page0.html
in a web browser. Don’t close it.page0.html
in a text editor and observe the code. Don’t close this file neither.Alt+Tab
on the keyboard.page0.html
in the text editor. For example, add your firstname where it should be.Warning
Learn the shortcuts: F5
to reload the page in the browser, Ctrl+S
to save your file in the editor.
Alt+Tab
shortcut is convenient to switch between the two applications.HTML is based on elements. An element indicates that a part of the document has a specific role.
For example, if you want to stress your name in the sentence, you can use the em
element.
The em
element is identified by a start tag and a end tag.
Here is an example. Try it!
My name is <em>Amélie</em>
And this is the result:
Most of the time, HTML elements have a start tag and a end tag.
Tags names are written inside angle brackets (greater than & less than symbols: “<” & “>”)
In the end tag, the tag name is preceded with a forward slash (/) sign.
For the element em, the start tag and end tag are:
<em> and </em>
This is your first web page, it is very important!
Try to use the <strong>
tag around the word first in the web page.
Admire the result in your browser.
Open page1.html
on your text editor and on your web browser (a good idea is to use a new tab in both cases).
<h1>
is for headings. Use it to define the title of the page.<p>
is for paragraph. Try it!Check the result on your web browser.
It’s time to add an image in your page.
The element for including an image is em and the corresponding tag is <img>
.
Here is an example:
<img src="TBL.jpg" alt="Inventor of the Web: Tim Berners Lee">
And this is the result:
<img src="mypicture.png" alt="This is my picture">
This tag has something new: alt
and src
are attributes.
Attributes specify behaviors of the tag.
Here, the src
attribute indicates where to find the image, and the alt
attribute defines an alternative text that will be displayed if the image cannot be loaded.
Warning
An img
tag does not need a closing tag.
It is quite rare.
Using the img
tag you have just learned, include in page1.html
a photo of Sir Tim Berners Lee. You will find and image in the directory named images
.
Be careful, as the photo is in the images
directory, and because it is named “Sir_Tim_Berners_Lee.jpg”, the alt
attribute should be: alt="images/Sir_Tim_Berners_Lee.jpg
.
HyperText is all about links... so let’s make links.
There are two types of links: internal links (between your pages) and external links (to the web). In both cases we use the same tag.
Let’s see an example:
<a href="http://www.w3c.org">Click here to go to the W3C web page</a>
Like the img
tag, the a
tag has an attribute: href
.
Like most of the other tags, the a
element has a start and a end tag.
Using the tag you’ve just learned (see below), add a link around the address at the bottom of the page.
<a href="http://www.w3c.org">Click here to go to the W3C web page</a>
Try it in your browser!
Making internal links is like making external links.
The only difference is that the href
attribute of the a
tag contains the name of the page you want to link instead of a web address.
For example, if you have two pages in the same directory, say page0.html
and page1.html
, then, on page0.html
, you can add the following code:
<a href="page1.html">This is a link to page 1</a>
It’s your time to try!
Add links on your pages and make sure you are able to navigate from one page to the other, and back.
HTML is the language we use to build web pages.
A web browser reads HTML code and interprets it to display the corresponding web page.
HTML defines many elements and is written with tags (start tag and end tag) such as <p>
and </p>
.
Some elements may have attributes such as in the followig example:
<a href="page3.html">This is a link to page 3</a>