Style Sheet
HTML TutorialHyper Text Markup Language |
|
|
|
This document will give an overview of the HTML Language.
It's targeted to be a jumpstart, for the users to get up to speed
with this way of publishing content, and be able to do it by themselves
after that...
|
| What's in a page | Top of Page |
HTML is a markup language (as opposed to a programming language), invented a couple of decades ago to provide and access content over the internet. Its specification now belongs to the W3C. To be visualized, the code of an html page has to be rendered by an HTML Browser (ie MS Internet Explorer, Netscape, etc).
The smallest HTML object than can be rendered is called a page. A page can be held in a text file, that's what we will take for granted in the remaining of this document. The HTML Directives are given - just like in any other markup languages - using tags, also called elements. An element can be opened or closed. It always begins with the character "<" and ends with the character ">". Generally, any element or tag you open has to be closed. To close an element, you need to prefix its name with the character "/". The top element of an HTML page is :
<html>
and as this html element has to be closed, the last element of an html page will have to be
</html>
In HTML, the tag's names is not case sensitive - like in XML - that means that <HTML> is equivalent to <html>.
In addition to the tag or element notion, we need to present the notion of attribute. The attribute can be seen as a parameter of an element. It has a name and a value. Theorically, its value must be given between double quotes.
<img src="picture.gif" alt="This is an image">
In the previous sample code,
Elements can be nested, they cannot overlap. That means that:
<elementOne>
<elementTwo>
CeciCela
</elementTwo>
</elementOne>
is a valid document. But a document like:
<elementOne>
<elementTwo>
CeciCela
</elementOne>
</elementTwo>
is invalid, and will produce unpredictable rendering.
Remember :
The present document is built using HTML... You can view its structure using the "View Source" feature of your browser.
| Basic Structure | Top of Page |
What you want to display will be declared in the body element of the html element. That means that the minimum structure of an HTML Page will have to be :
<html>
<body>
</body>
</html>
For example :
| A code like | Will produce a page looking like | If you don't believe me... |
<html>
<body>
This is an example
</body>
</html>
|
This is an example | Click here. |
<html> and <body> are part of the html language. <body> can have several attributes, like bgcolor, text, link, alink, vlink, ...
To structure your html document, you can use paragraphs. The paragraph tag is <p>.
Header tags are also available. This tag works like this :
| A code like | Will produce a page looking like | If you don't believe me... |
<html>
<body>
<h1>Header 1</h1>
<h2>Header 2</h2>
<h3>Header 3</h3>
<h4>Header 4</h4>
</body>
</html>
|
Header 1Header 2Header 3Header 4 |
Click here. |
| A First Page | Top of Page |
This first lab will make you manipulate the basic concepts we just mentioned above. You will produce different basic pages, changing the colors and fonts of the characters and backgrounds.
| Lab 1: your first HTML Document |
| What to do |
<html>
<body>
This is my first example
</body>
</html>
... and you should obtain what you see if you click here.
Then modify the previous content to have it look like :
<html>
<head>
<title>Lab One</title>
</head>
<body>
This is my first example
</body>
</html>
... that should display something like this. Have
you noticed where the difference is?
The let's use the Headers tag, plus some color features. Try this :
<html>
<head>
<title>Lab One</title>
</head>
<body>
<h1>This is my first example</h1>
</body>
</html>
... and that :
<html>
<head>
<title>Lab One</title>
</head>
<body text="yellow" bgcolor="black">
<h1>This is my first example</h1>
</body>
</html>
The final result should be this.
When you're done with the samples written above, try the following code :
<html>
<head>
<title>Lab One</title>
</head>
<body text="yellow" bgcolor="black">
<h1>This is my first example</h1>
Here is some content,
written in two lines in the document.
<br>
Now after the break.
<p>
Into a new paragraph
</p>
<p>
Some samples : <b>bold</b>, <i>italic</i>, <u>underlined</u>, <b><i><u>all together</u></i></b>.
</p>
<hr>
<address>© 2001, Oliv Soft</address>
</body>
</html>
This should be rendered as in this document.
| More Complex... | Top of Page |
| Images | Top of Section |
Images are to be considered as documents included in your page. Images will be accessed through
their URL, just like an HTML page. The basic tag to access an image is <img>.
The IMG tag has two main attributes, src and alt.
<img src="image.gif" alt="Alternate text">
Notice that the IMG tag doesn't need to be closed.
Assuming that a file named atwork.gif exists in the directory where the present document is,
| A code like | Will produce a page looking like | If you don't believe me... |
<html>
<body>
<p align="center">
<img src="atwork.gif" alt="Work in progress">
</p>
</body>
</html>
|
|
Click here. |
| Lab 2: Show an image |
| Lists | Top of Section |
Lists are a specific way to present some structured content. They are mainly made out of two elements:
<ul> <!-- List type -->
<li>One</li> <!-- List item -->
<li>Two</li>
<li>Three</li>
</ul>
|
|
Nested lists have a default behavior:
<ul>
<li>One</li>
<li>
Two
<ul>
<li>Two-One</li>
<li>Two-Two</li>
<li>
Two-Three
<ul>
<li>Two-Three-One</li>
<li>Two-Three-Two</li>
<li>Two-Three-Three</li>
</ul>
</li>
</ul>
</li>
<li>Three</li>
</ul>
|
|
| Tables | Top of Section |
Tables are a very big topic. Basically, the table involves three elements:
<table>
<tr>
<td>
Akeu
</td>
<td>
Coucou
</td>
<td>
Larigou
</td>
</tr>
<tr>
<td>
Coucou
</td>
<td>
Larigou
</td>
<td>
Zébulon
</td>
</tr>
</table>
|
|
If you don' believe me, click this. |
The previous sample with <table width="98%" border="1"> renders this:
| Akeu | Coucou | Larigou |
| Coucou | Larigou | Zébulon |
To have a column taking the room of two (or several), use the colspan attribute at the <td> level:
<table width="98%" border="1">
<tr>
<td colspan="2">
Akeu
</td>
<td>
Coucou
</td>
</tr>
<tr>
<td>
Coucou
</td>
<td>
Larigou
</td>
<td>
Zébulon
</td>
</tr>
</table>
|
|
||||||
Same for the rows, use the rowspan attribute at the <td> level:
<table width="98%" border="1">
<tr>
<td rowspan="2">
Akeu
</td>
<td>
Coucou
</td>
<td>
Coucou
</td>
</tr>
<tr>
<td>
Larigou
</td>
<td>
Zébulon
</td>
</tr>
</table>
|
|
| HyperLinks and Anchors | Top of Section |
Hyperlinks provide the possibility to
For example, if from some link you want to go to http://www.yahoo.com, you have to type a statement like this :
Do you <a href="http://www.yahoo.com">Yahoo</a> ?
|
Do you Yahoo ? |
Now, to navigate within the same document, or to a specific part of an external document,
you have to use the name attribute of the anchor element, and the # sign in your URL.
The document you are reading now is using such a feature to bring you back to the Top of the Page,
or to the Top of the Section.
To name an anchor, use the following syntax:
<a name="MyAnchorName">Come here</a>
To go to this anchor, use:
<a href="#MyAnchorName">Go there</a>
One last thing before moving forward, the target attribute. It can be used in conjunction with the <a> element to open the link into another window. For example, you can write
<a href="http://www.yahoo.com" target="Yahoo">Yahoo!</a>
|
Yahoo! |
<a href="http://www.yahoo.com">Yahoo!</a>
|
Yahoo! |
This feature involves several elements.
<img src="4Camels.jpg" usemap="#CamelMap" alt="Four camels" border="0">
<map name="CamelMap">
<area shape="rect"
coords="0,0,42,42"
href="http://www.yahoo.com"
target="Yahoo"
alt="Yahoo">
<area shape="rect"
coords="43,0,95,42"
nohref
alt="Second Camel"
onClick="alert('No link on this one');">
<area shape="rect"
coords="96,0,138,42"
href="http://www.google.com"
target="Google"
alt="Google">
<area shape="rect"
coords="139,0,190,42"
href="http://www.mapquest.com"
target="Mapquest"
alt="Mapquest">
</map>
and as a result, we obtain:
| Frames | Top of Section |
Using frames is the way to display several documents in the same window. Each frame will be embedded in the same window, but will actually act just like a genuine window.
You will need :
<html>
<head>
<title>The top document</title>
</head>
<frameset rows="25%,*" cols="100%">
<frame src="TopDocument.html" name="TopDoc">
<frameset cols="30%,*">
<frame src="LeftDocument.html" name="LeftDoc">
<frame src="RightDocument.html" name="RightDoc">
</frameset>
</frameset>
</html>
|
Click Here. |
<html>
<head>
<title>The top document</title>
</head>
<frameset rows="25%,*" cols="100%" frameborder="no">
<frame src="TopDocument.html" name="TopDoc">
<frameset cols="30%,*" frameborder="no">
<frame src="LeftDocument.html" name="LeftDoc">
<frame src="RightDocument.html" name="RightDoc">
</frameset>
</frameset>
</html>
|
Click Here. |
The name attribute of the <frame> element
can be used in conjunction with the target attribute of the
<a> element, to click a link in one frame, and open
the corresponding document in another frame.
Let's take an example. Let's write the LeftDocument.html mentionned above like this:
<html>
<head>
<title>Left Frame</title>
</head>
<body>
<h1>This is the left frame</h1>
<a href="http://www.yahoo.com" target="RightDoc">
Yahoo!
</a>
</body>
</html>
|
Click Here. |
Some target window or frame names are reserved, like:
<html>
<head>
<title>Left Frame</title>
</head>
<body>
<h1>This is the left frame</h1>
<a href="http://www.yahoo.com" target="_parent">
Yahoo!
</a>
</body>
</html>
|
Click Here. |
| Lab 3: Building a frameset |
This lab will put together several of the features we've seen so far. We want to have a three-frame document, with a title on top - feel free to play with colors - three active images on the left pane to display Yahoo!, Google and Mapquest in the right pane.
We want the result to look like this.
Do it the way you like!
| Special Characters | Top of Section |
Characters like ©, ®, ° can be displayed using special characters. It should be used as well to display accented characters, like é, à, ñ or ö. This feature can be pretty powerful, and used to display formulas, like in :
| f(t) = |
|
|
ti(1-t)n-i Pi |
|
¶S
--- = ¶a |
2aSx4 + 2bSx3 + 2cSx2 - Syx2 = 0 |
| Styles and Stylesheets | Top of Section |
For advanced users...
| JavaScript | Top of Section |
A Object Oriented Programming Language for a static document... Wow ! A document like this :
<html>
<body bgcolor="#9BC9FB" text="navy">
<font face="Helvetica">
<script language="JavaScript">
<!--
document.writeln('<font face="courier">');
document.writeln('<ul>');
for (i=32; i<=255; i++)
document.writeln("<li>Character #" + i + "=[" + i + ";]</li>");
document.writeln('</ul>');
document.writeln("Character ETH=[Ð]");
document.writeln("Character eth=[ð]");
document.writeln('</font>');
// -->
</script>
<hr>
<address>© 2001 and beyond, Oliv Cool Stuff Soft</address>
</font>
</body>
</html>
would display... this.
| Some advices | Top of Page |