| On this page: |
top ↑ |
|||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||
| How to use this tutorial |
top ↑ |
||
|---|---|---|---|
|
|||
| How this page is organised |
top ↑ |
||
|
|||
| Tags for page structure: |
top ↑ |
|
|---|---|---|
| paragraph | headings | list | ||
| paragraphs | ||
Make paragraphs:<p> - the paragraph tag
Creates a paragraph. Puts extra space above and below. |
example code: <p>
Here is a paragraph.
Notice that the browser doesn't care about
"white space".
The browser will make one long line for the paragraph,
and it will "wrap" the line to the width of the paragraph.
</p>
<p>
Here is another paragraph, to show how the p
tag will put some space between paragraphs.
</p>
result in web page: Here is a paragraph. Notice that the browser doesn't care about "white space". The browser will make one long line for the paragraph, and it will "wrap" the line to the width of the paragraph. Here is another paragraph, to show how the p tag will put some space between paragraphs. |
|
Aligns a paragraph horizontally. "DIRECTION" is either "left", "right", or "center". |
example code: <p>
This paragraph is aligned to the left.
(If you don't give any "align" at all,
the paragraph will always align to the left.)
</p>
result in web page: This paragraph is aligned to the left. (If you don't give any "align" at all, the paragraph will always align to the left.) example code: <p align="right">
This paragraph will be aligned to the right.
It will still be the full width – the right
edge will be lined up, instead of the left.
</p>
result in web page: This paragraph will be aligned to the right. It will still be the full width – the right edge will be lined up, instead of the left. example code: <p align="center">
This paragraph will be aligned in the center.
We don't use this very often, because it is
hard to read.
</p>
result in web page: This paragraph will be centered. We don't use this very often, because it is hard to read. |
|
Make a line break:
<br />
You can use the break tag for any text: in paragraph, headings, lists – anywhere.
We don't use this tag often.
|
example code: <p>
Here is some text <br /> and some more.
</p>
result in web page:
Here is some text
and some more. |
|
| headings | ||
Make page headings and sub-headers:Don't confuse the 'heading' tags (<h1>, <h2>, etc.) with the 'head' tag (<head>) they are different! <hl> - the heading tag <hl>some text</hl> Creates the top-level headline – the title of your page |
example code:
<h1>
This is a level 1 heading
</h1>
result in web page: This is a level 1 heading |
|
|
<h2>some text</h2> Creates a second-level headline – a subsection of your page. The heading tag goes down to level 6 (<h6>), but we usually don't go down further than h3. |
example code:
<h2>
This is a level 2 heading
</h2>
result in web page: This is a level 2 heading |
|
| lists | ||
|
||
ordered lists:
<ol></ol>
<li></li>
|
example code: <ol>
<li> ice cream </li>
<li> oats porridge </li>
<li> chocolate </li>
</ol>
result in web page:
|
|
unordered lists
<ul></ul>
<li></li>
|
example code: <ul>
<li> ice cream </li>
<li> oats porridge </li>
<li> chocolate </li>
</ul>
result in web page:
|
|
definition lists
<dl></dl>
<dt>term</dt>
<dd>definition</dd>
We don't use the definition list very often. |
example code: <dl>
<dt> ice cream </dt>
<dd> Food of the gods. </dd>
<dt> oats porridge </dt>
<dd> A delicious and filling
breakfast, especially in winter. </dd>
<dt> chocolate </dt>
<dd> The best chocolate is
bittersweet and hard to bite. </dd>
</dl>
result in web page:
|
|
| Formatting text |
top ↑ |
|---|---|
| Here are the html tags for making text bold or italic. We don't use these tags very often. To change font size, color, and many other nice things, we usually use stylesheet (css) language. | |
|
<b> - the bold tag <b>some text</b> Makes text to be bold |
example code: <p>
Here are some <b>bold words</b>.
</p>
result in web page:
Here are some bold words.
|
|
<i> - the italic tag <i>some text</i> Makes text be italic. |
example code: <p>
Here are some <i>italic words</i>.
</p>
result in web page:
Here are some italic words.
|
| Links |
top ↑ |
|
|---|---|---|
Links are what the web is all about!
The <a> tag makes links.
|
||
|
Linking to websites, pages, or parts of a page: <a> - the a tag. Makes an anchor. <a href="URL">some text</a> creates a link, or hyperlink reference. The "URL" is the web address. It is the name of the file you want to go to. It can be a file on your website, or another website. "some text" is the words that the user will see in the web browser, that they can click on. |
||
Link to a website:http:// tells the web browser, that we want to go to a different website. The section between the // and the next / is the "domain name" or "host name" of the website. Anything after that is the path to the web page you want to link to. |
<p>
The
<a href="http://tibetangeeks.com/">
TibetanGeeks.com</a>
pages have (almost) everything
James knows about the web.
</p>
result in web page:
The
TibetanGeeks.com
pages have (almost) everything James knows about the web.
|
|
Link to another page on your website: |
example code: <p>
Read about
<a href="3-how_to_fix_html_problems.html">
how to fix html problems</a>.
</p>
result in web page:
Read about how to fix html problems.
|
|
Link to a location in the same web page:This requires two tags:
The "target" location has an id:
Any tag can have an id. So your target could be a paragraph, a subheading,
an image, etc. For example:
Then the link gives that target name, with a #:
|
example code: <p id="here">
Here is the target.
</p>
result in web page:
here is the target
example code: <p>
Click to go to the <a href="#here">target</a>.
</p>
result in web page:
Click to go to the target.
|
|
Link to a location in another web page:This also requires two tags:
The "target" location with the id, is in the page you want to link to:
Then the link gives that web page filename, and the target name with a #:
|
example code – This is in another page: 4-html_faq.html <th id="writing_good_code">
writing good code
</th>
result, in the web page 4-html_faq.html
example code, in this page: <p>
Read about how to
<a href="4-html_faq.html#writing_good_code">
write good code</a>.
</p>
result in this page:
Read about how to write good code.
|
|
| Graphical Elements |
top ↑ |
|---|---|
| images | |
Show an image (photo, graphic, etc):<img> - the img tag. Displays an image in the page.
<img src="LOCATION"
src means "source".
alt means "altternate".
There are other
attributes
we can use for the img tag:
width, height, align, and more.
(Remember that the image is still a separate file. It does not become part of your html file, as it would for instance in MSWord become part of your Word file.) |
example code: <img src="images/dalai_lama-sm.jpg"
alt="His Holiness Dalai Lama" />
result in web page:
An image seems like it would be a "block tag", because we see a rectangle in the browser. But the img tag is actually an inline tag: Images will float next to other images or text, inline. We can tell the image which direction to float, with the align attribute: example code: <p>
<img src="images/dalai_lama-sm.jpg"
align="right"
alt="His Holiness Dalai Lama" />
Here is a picture of His Holiness ...
</p>
result in web page:
|
Movies, sound, etc. |
|
| Tables |
top ↑ |
|||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| The <table> tag was invented for scientists to display their data, the same way you would use an Excel spreadsheet. In the old days we also used table code to lay out our page design. Now we use <div> tags and CSS language for page design. | ||||||||||||||||||||||||||||||||||||||||||
making a table<table> - the table tag
table attributesTo see how to use these attributes, look at the code for the example tables to the right.
<td colspan="NUM">
<td rowspan="NUM">
<table border="NUM">
<table cellpadding="NUM">
<table cellspacing="NUM">
<table width="NUM">
Later we will learn how to do all these things with CSS language. column (cell) display attributesA "column" (cell) is a <td> or a <th> We can use CSS language to set the width and text alignment of a cell:
<td style="width: NUM;">
<td style="text-align: ALIGN">
|
examples: here is a simple (and boring) table: <table>
<tr>
<td>one</td>
<td>two</td>
<td>three</td>
</tr>
<tr>
<td>༡</td>
<td>༢</td>
<td>༣</td>
</tr>
</table>
The same table with some attributes <table cellpadding="20" cellspacing="0" border="1">
<tr>
<td>one</td>
<td>two</td>
<td>three</td>
</tr>
<tr>
<td>༡</td>
<td>༢</td>
<td>༣</td>
</tr>
</table>
Using th (table heading)
<table cellpadding="8" cellspacing="0" border="1">
<tr>
<th colspan="3">Parts of Tibet</th>
</tr>
<tr>
<td>Amdo</td>
<td>Kham</td>
<td>Lhasa</td>
</tr>
<tr>
<td>Dhomey</td>
<td>Dho du</td>
<td>U-Tsang</td>
</tr>
</table>
Now what can we do with tables!
One example: Check your email: the lines of emails with date, subject, and who from is made with table code.) Below are some small examples. (They are using CSS language for the colors, background, etc.)
This table is used to display images.
This table uses a small repeating image for the background.
This table uses one image for the background.
|
|||||||||||||||||||||||||||||||||||||||||
| Table exercise |
top ↑ |
|---|---|
| When you are able to lay out a complicated table, you will be ready to do page design and learn CSS language. | |
|
Exercise 1:
Follow the instructions below: ↓
Hints:
|
|
|
Exercise 2:
Follow the instructions below: ↓
Hints:
|
|
| Three kinds of tags |
top ↑ |
|---|---|
|
|
| A real web page |
top ↑ |
|---|---|
|
Real web pages have some basic parts that we always use on real websites. The page tags tell the browser which part of the web page is information for the browser (in the <head> tag), and which part is to be displayed (in the <body> tag). |
|
Two little things: doctype and meta character set tagsA web page is like many parts in a little machine. So we need to tell the web browser some things to help it run our machine.
This template shows where we put the doctype and character set tags. All your web pages should have these two things. You don't really need to know everything about these now! Just do it :) Later we can learn more what these are all about. |
|
The structure of a web page |
|
|
<html> </html>
<head> </head>
<body> </body>
|
example code: Here is the code for a basic web page: <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>
Your Page Title Goes Here
</title>
<link rel="stylesheet" href="/path_to_css_file/style.css" />
</head>
<body>
<h1>
Your Page Heading
</h1>
<p>
Your content goes here.
With more tags and images and all the good things.
</p>
</body>
</html>
And this will make a web page that looks (more or Your Page Heading Your content goes here. With more tags and images and all the good things. |
Title Tag |
|
|---|---|
|
<title> - the title tag Puts the text in the title bar of the browser. The title tag never has any attributes, and there are never any html tags in the text of the title. The title may seem like a small thing, but it can be really helpful, or very unhelpful, to your user: The title text is also used by the browser in its history list, bookmarks ("favorites"), and 'back' and 'forward' button menus. Also it is used by search engines, to display when they find your page. |
example code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>
My Great Page
</title>
</head>
Now the title bar at the top of the web browser will say "My Great Page". |
Body Tag |
|
|---|---|
|
<body> - the body tag The body tag holds the content that you see in the browser. That is, everything that the user sees in the web page, is inside the <body> tag. All the block and inline tags go between the <body> tags.
<body>
all the content of the web page goes here </body> |
example code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>
My Great Page
</title>
</head>
<body>
<p>
all page content goes here.
</p>
</body>
</html>
result in web page: all page content goes here. |
Comment Tag |
|
|---|---|
|
And here's one last thing, that is not required, but is very useful to you: <!-- --> - the comment tag The comment tag is for notes you want to make for yourself. Nothing inside the comment tag is seen on the web page. |
example code:
<-- note to self -->
<p>
all page content goes here.
</p>
result in web page: all page content goes here. |
| More information |
|---|
|
|
This page has only the most common tags. There are more! |
|
| copyright / license |
top ↑ |
|---|---|
|
Q: Can i copy this file? Can i give to other people? Answer: Sure, you can give it to anyone, according to the terms of the license below. It is copyright © 2004 James Walker. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included here. If not found, find it at www.fsf.org - the Free Software Foundation. |
|
| translation |
top ↑ |
|---|---|
|
It would be very useful to have translations of this document in any language. Most preferred would be Tibetan and Chinese. Please contact me if you can do a translation for us. |
|
| contact |
top ↑ |
|---|---|
|
Was this helpful? Is it clear, or confusing? I would be happy to hear anything about how to make this better. You can contact me at the email address i have given you, or at http://www.webwalker.to/contact.php |
|