Thursday, May 3, 2007

HTML Basic Structures

Headings

The heading structures are most commonly used to set apart document or section titles. For example, the word "Headings" at the beginning of this section is a heading. So is this document's title (it's at the top of the page, in case you somehow missed it).

** WARNING ** Remember that these heading structures go into the body of the document. The headings being discussed here have nothing to do with the HEAD structure from the previous chapter.

There are six levels of headings, from Heading 1 through Heading 6. Heading 1 (H1) is "most important" and Heading 6 (H6) is "least important." By default, browsers will display the six heading levels in the same font, with the point size decreasing as the importance of the heading decreases. Here are all six HTML pairs, in descending order of importance:

Heading 1


Heading 2


Heading 3


Heading 4


Heading 5

Heading 6


These six lines, when placed into an HTML document, will simply display the six levels of headings. Take a look.

Since, as we have discussed, whitespace doesn't matter, you might think that the above block of HTML would just string the content into one line of text. However, because headings are meant for section titles and the like, they are defined as existing on a line by themselves. A heading always begins at the margin of a line and always forces a line break at the end of the heading. In other words, you cannot have two heading levels on the same line.

This also means that you cannot highlight text in the middle of a paragraph by marking it as a heading. If you try this, the paragraph will be split in two, with the heading text on its own line between the two pieces. (Later on, we'll talk about ways of highlighting text.)

** ASIDE ** If you have a browser which is set close to its default settings, you'll notice that the text for the last two headings gets pretty small. This leads to some page designers using H6 for the fine print at the bottom of pages. This is a mistake, not to mention an abuse of the heading structure. As you no doubt know, many browsers allow the user to set the size of each element, including the headings. If a user sets H6 to a size of 18 point, the fine print won't be so fine any more! Remember: you cannot guarantee that your document will appear to other people exactly as it does to you.
Paragraphs

As you might suspect, paragraphs are quite common in Web pages. They are one of the most basic structures in HTML. If you regard a document as a collection of structures and sub-structures, you may come up with something like:

The overall structure is a page. The page is composed of a number of sections, each of which is composed of one or more paragraphs. Each paragraph is composed of words, and each word of letters.

Admittedly, this is a simplified way of looking at text, but it will do for our purposes. The furthest HTML goes down this progression is to the paragraph level.

The beginning of a paragraph is marked by

, and the end by

. This tutorial is obviously filled with examples of this container, and you can look at the following example page to get a more direct idea of how the paragraph tag works.

Let's say you want to create a paragraph. You start to wonder, "What happens if I hit return at the end of every line in the paragraph? Should I make the paragraph just one long continuous line? What if I accidentally put too many spaces between words?"

At this point, you should once again be saying to yourself: whitespace doesn't matter. You could put each word on its own line, and the paragraph would look completely normal. In fact, no matter how much whitespace you put between words, whether returns or spacebar hits, the words will be separated by one space in a Web browser.

Got all that? If you're not sure you completely understand, go through the section again -- or better still, try it on your own.
Line Break

So what if you want to end a line after a certain word, but don't want to start a new paragraph? Well, what you need is a line break, which is invoked by using the
tag. This forces a line break wherever you place it in the content (that is, whatever is after the
tag will start from the left margin of the next line on the screen.)

And no, there is no
tag. The line break tag is -- that's right! -- an empty tag. And when you think about it, this makes sense. The concept of a line break beginning and ending doesn't really work, since a line break is a one-shot occurrence.

Try it yourself, or look at an example.
Blockquote

Blockquotes are handy for those long pieces of text which are quoted material and therefore need to be set apart and indented. That is exactly what blockquote does. For example:

This section of text is surrounded by the blockquote tags. A blockquote can exist inside of a paragraph, and always lives on its own line (which is to say, there is an implied line break before and after the blockquote, just as with headings or paragraphs themselves).

Blockquotes are set up as follows:

...text...


Just like most other things in HTML, it's a container.

HTML Concepts

Assumptions

In the writing of this document, I have made certain assumptions which I should state clearly. The first is that you are using a graphical web browser such as Netscape, Mosaic, etc., and not a character-based browser such as Lynx. I have tried to keep my explanations and examples as "universal" as possible, but I make no guarantees as to this.

The second is that you are somewhat familiar with the operation of a Web browser and have already visited several Web sites. If this is not the case, you should do so before starting this tutorial. If you're looking for something which will explain various terms you've seen or heard, try the Beginner's Web Glossary.

The third thing is that when I talk about text, or content, or things of that nature, I am generally not referring to what appears in the Web browser. I'm talking about what is in the actual HTML file. There can be a big difference; make sure you know what I'm talking about. If you can't make heads or tails of it, email me and let me know there's a problem. Thanks!
Terms

There are a few common terms which I will use again and again. I'll just quickly define them here. Again, if you're looking for a comprehensive list of terms, try the Beginner's Web Glossary.

Content
The actual 'meat' of a document -- all of the words, images, and links which a user can read and interact with. I use this term a lot to mean "whatever you put in the document."
Hyperlink
A link from one document to another, or to any resource, or within a document. For example, just above where its says "Beginner's Web Glossary" and that text is highlighted in some fashion. The default is usually blue, underlined text, but your display may vary.
In-line
Almost always used in the context "in-line image," this refers to a resource of some type which is placed directly into a document. As I say, this is nearly always an image, but the future could see things like in-line animations.
URL
The Uniform Resource Locator is a "standard" way of easily expressing the location and data type of a resource. URLs in general take the form "protocol://address" where protocol is something like gopher, FTP, telnet, and so on, and the address is merely the server and pathname (if any) of a given resource or page. For more information, take a look at the Beginner's Guide to URLs at the National Center for Supercomputing Applications (NCSA).

Your Web Browser

The part of your Web browser I'll mention most often is the browser display window (also the display window or browser window). This is the part of the Web browser where the actual contents of an HTML document are displayed.

Yes, that's right, the text you're reading at this very moment is in the browser display window.

The other thing I'll mention is the history list (sometimes called the go list). That's the list of pages you've visited during the current session. In most browsers, it is available as either a menu or a pop-up dialog box.
Writing to the Norm

No, not the fat guy on "Cheers." Actually, it's a fundamental issue every Web author needs to know about and appreciate.

Web browsers are written by different people. Each person has their own idea about how Web documents should look. Therefore, any given Web document will be displayed differently by different browsers. In fact, it will be displayed differently by different copies of the same browser, if the two copies have different preferences set.

Therefore, you need to keep this principle foremost in your mind at all times: you cannot guarantee that your document will appear to other people exactly as it does to you. In other words, don't fall into the trap of obsessively re-writing a document just to get it to "fit on one screen," or so a line of text is exactly "one screen wide." This is as pointless as trying to take a picture that will always be one foot wide, no matter how big the projection screen. Changes in font, font size, window size, and so on will all invalidate your attempts.

On the other hand, you want to write documents which look acceptable to most people. How? Well, it's almost an art form in itself, but my recommendation is that you assume that most people will set their browser to display text in a common font such as Times at a point size of somewhere between 10 and 15 points. While you shouldn't spend your time trying to precisely engineer page arrangement, you also shouldn't waste time worrying about how pages will look for someone whose display is set to 27-point Garamond.
HTML: Behind the Scenes

HTML is composed of tags. HTML tags are always enclosed in angle-brackets ( < > ) and are case-insensitive; that is, it doesn't matter whether you type them in upper or lower case. I almost always use upper case, because it makes the tags easier to pick out in a document, but that's just me. You can do whatever you like.

Tags typically occur in begin-end pairs. These pairs are in the form
where the indicates the beginning of a tag-pair, and the indicates the end. (The three dots indicate an arbitrary amount of content between the tags.) The usual way to refer to each tag is "tag" for the first and "slash-tag" for the second, where tag is the actual name of the tag being discussed.

These pairs define containers. Any content within a container has the rules of that container applied to it. For example, the text within a "boldface container" would be boldfaced. Similarly, paragraphs are defined using a "paragraph container."

Thinking of tag-sets as containers will help in another way: it will help you remember that tags should always be balanced. In other words, you should keep containers nested within each other, just as you would have to do in the real world. Let's try some visual examples where we actually draw the containers:
Figure 1: lines drawn to illustrate overlapping versus non-overlapping containers
Why should you worry about this? Well, if you start overlapping containers as shown on the right, about the best you can expect is that the document will be formatted in unexpected ways.

One more thing to keep in mind with regards to containers. Since HTML is based on these structures, it is often the case that the arrangement of text within a container is irrelevant. For example, within a paragraph container, all of the text can be in one long line, or in a series of separate lines, or with every word on its own line, or with every word separated from every other by nineteen spaces. These would all be displayed exactly the same.

Therefore, try to keep in mind this thought: whitespace doesn't matter. (Whitespace is all of the blank areas in a text file--empty lines, extra spaces, and so on.) I'll mention this again when discussing the paragraph tag, and it will crop up in other places. Again: whitespace doesn't matter.

Having said all that, I will now attempt to muddy the waters a bit by mentioning that not every tag in HTML is paired. Some tags, such as the line-break tag, stand on their own (that is, they have no closing tag). These are known as empty tags. As we encounter them, I'll point them out.
All Right Already!

HTML - HyperText Markup Language

HTML

(HyperText Markup Language) The document format used on the Web. Web pages are built with HTML tags (codes) embedded in the text. HTML defines the page layout, fonts and graphic elements as well as the hypertext links to other documents on the Web. Each link contains the URL, or address, of a Web page residing on the same server or any server worldwide, hence "World Wide" Web.

HTML 2.0 was defined by the Internet Engineering Task Force (IETF) with a basic set of features, including interactive forms capability. Subsequent versions added more features such as blinking text, custom backgrounds and tables of contents. However, each new version requires agreement on the tags used, and browsers must be modified to implement those tags. See HTML tag.

HTML Itself Is Not a Programming Language

HTML is a markup language (the ML in HTML) that uses a fixed set of markup tags. A markup language can also be thought of as a "presentation language," but it is not a programming language. You cannot "if this-do that" like you can in Java, JavaScript or C++. However, in order to make pages interactive, programming code can be embedded in an HTML page. For example, JavaScript is widely interspersed in Web pages (HTML pages) for that purpose. See JavaScript and VBScript.

HTML was conceived as a simple markup language to render research documents. No one originally envisioned Web pages turning into multimedia extravaganzas. HTML pages have been reworked, jury-rigged and extended into full-blown applications. As a result, the source code behind today's Web pages is often a hideous concoction of tags and scripting. See HTML tag, XML, XHTML and SGML.

World Wide Web Linking
Accessing a Web document requires typing in the address, or URL (Uniform Resource Locator), of the home page in your Web browser. The home page is an HTML document, which contains hypertext links to other HTML documents that can be stored on the same server or on a server anywhere in the world.

Web Server Fundamentals
Web browsers communicate with Web servers via the TCP/IP protocol. The browser sends HTTP requests to the server, which responds with HTML pages and possibly additional programs in the form of ActiveX controls or Java applets.

Three Related Articles from CMP's TechWeb

* Worm Attack: A Grudge Match With Symantec?

* "Hi, I'm Bob, and I'm an E-mailholic"

* Adobe Photoshop Online Faces Disinterest From Photo Pros

* Find the latest news, features and reviews relating to "HTML" from CMP's TechSearch.

HTML Real Tutorial

WRITING HTML WAS CREATED way back in 1994 to help teachers create learning resources that access information on the Internet. Here, you will be writing a lesson called Volcano Web. However, this tutorial may be used by anyone who wants to create web pages. You can get a sense of the results by looking at our illustrious alumni and kudos or what people say about the tutorial.

By the time you have reached the end of this tutorial you will be able to construct a series of linked web pages for any subject that includes formatted text, pictures, and hypertext links to other web pages on the Internet. If you follow the steps for the Basic Level (lessons 1-14) you will develop a page about volcanoes and if you go on to the Advanced Level (lessons 15-29), you will create an enhanced volcano web site.

For faster performance, you can download an archive of all files used in this tutorial as well as a printable version of the lessons. Most of the lessons can be done off-line. If you are having trouble connecting to this site, try our Zircon server but please be nice to these machines; they are doing other work for us.
Why Create Web Pages?

If you've come this far, you likely have an answer.


THE WEB IS BECOMING AN INTEGRAL PART of our working (and playing) world. You cannot spit anymore these days without hitting a URL (if you do not know what a URL is, you will find out here). In a very short time span, the web has revolutionized the way we access information, education, business, entertainment. It has created industries where there were none before.

Being able to develop information on the web might be a job skill, a class requirement, a business necessity, or a personal interest. Unlike any other previous medium, the ability to "write" HTML allows you to potentially connect with millions of other people, as your own self-publisher.
Objectives

This tutorial covers the steps for writing HTML files using illustrative examples for creating web pages.


IN THESE LESSONS YOU WILL:

* identify and use different HTML formatting codes.
* create and modify HTML documents using a simple text editor.
* write a series of web pages that present information, graphics, and provide hypertext links to other documents on the Internet.

And maybe you will have some fun!
What
is
HTML?

HyperText Markup Language


PUT MOST SIMPLY, HTML, is a format that tells a computer how to display a web page. The documents themselves are plain text files (ASCII) with special "tags" or codes that a web browser knows how to interpret and display on your screen.

This tutorial teaches you how to create web pages the old-fashioned way -- by hand. There are software "tools" that allow you to spin web pages without touching any HTML. But if you are serious about doing more than a page or two, we believe a grounding in the basics will greatly accelerate what you can do.

Everything you create in this tutorial is designed to run from any desktop computer; it does not depend on access to a web server or specialized computer programming.
Getting Ready

We will assume you have a basic knowledge of how to use your web browser menus, buttons, and hypertext links.


YOU WILL ALSO NEED A TEXT EDITOR PROGRAM capable of creating plain text files e.g. SimpleText for the Macintosh or NotePad for Windows. We strongly urge that you use the most basic text editor while you learn HTML and then later you can explore HTML "editors" If you use a word processor program then you must save your files as plain ASCII text format. You should also be familiar with switching between multiple applications as well as using the mouse to copy and paste selections of text.

If you download the tutorial files, you can do nearly all of the lessons off-line.

We suggest that you proceed through the lessons in order, but at any time you can return to the index to jump to a different lesson. Within each lesson you can compare your work to a sample file for that lesson. Each lesson page has a link to a concise summary of the tags as well as links to other reference sites.

For convention, all menu names and items will be shown in bold text. All text that you should enter from the keyboard will appear in typewriter style.
Keep in Mind

Some pointers to help you out, since we will never admit knowing everything.


1. Use the Favorites or Bookmark feature of your web browser to mark the lesson index page so you can easily navigate to other lessons.
2. We've aimed to write instructions generic to (almost) any web browser; sometimes the menu names or features may not match the web browser you are using.
3. This tutorial will show you how to create web pages that can see outward to the world. It will not tell you how to let the world see them; to do this you need to locate an Internet Service Provider that provides web server space. Try The List, ISPGuide, SearchAnISP or c|net Internet Services. Also, you can search for a free web page hosting service from Freewebspace.net
4. Creating pages is one thing, designing web sites is another. We cannot highly enough recommend the Yale C/aIM WWW Style Manual. Sun Microsystem's Guide to Web Style, and the Sevloid Guide to Web Design.
5. When you are ready for the big time, see web pages like you have never seen web pages at Dave Siegel's Casbah and High Five sites. Trudge on over to his Web Wonk to get the details. It will amaze you.
6. Refer to the HTML tag summary page as a reference. You can get to it by following the hypertext link at the top of every lesson page.
7. If you are having trouble, see the Writing HTML FAQ (Frequently Asked Questions) before writing us for help. We get lots and lots of e-mail. Too much.

Who Did This?

Roll the credits!


THIS IS A PROJECT of the Maricopa Center for Learning and Instruction (MCLI). Writing HTML was developed by Alan Levine, instructional technologist at the Maricopa Community Colleges. Our former intern, Tom Super, provided invaluable instructional design support. Many others have given helpful suggestions, corrected typos, and expressed their thanks!

Once your web pages become available on the Internet, please list them on our Writing HTML Alumni page using our registration form.

Thanks to some great volunteer efforts, Writing HTML is also available in other languages:

* Spanish / Español v3.0 (thanks to Arturo García Martín and Andrés Valencia)
* French "Ecrire le HTML" v4.5.2 (thanks to Bernard Bensoussan)
* Icelandic / Íslenska "Námsefnisgerð í HTML" v 4.5.2 (thanks to Gudjon Olafsson)
* Korean v4.5 (thanks to Dr. Byeong Choon Lim, Department of Computer Education Chuncheon National University of Education) (This site will not be available during 2002, stay tuned.)
* Italian "Corso di HTML" v4.5.1 (thanks to Cristiana Cavicchi)
* Japanese v 4.0.` (thanks to kazuaki mizota) (This site is no longer available, try sites found from Internet Archive "WayBack Machine")

Wednesday, April 4, 2007

HTML Tutorial

HTML Tutorial


Definition and Usage

The body element defines the documents' body. It contains all the contents of the document (like text, images, colors, graphics, etc.).


Differences Between HTML and XHTML

All "presentation attributes" of the body element were deprecated in HTML 4.01.

All "presentation attributes" of the body element are not supported in XHTML 1.0 Strict DTD.


Example


<html>
<head>
</head>

<body>
The content of the document......
</body>

</html>




Optional Attributes

DTD indicates in which DTD the attribute is allowed. S=Strict, T=Transitional, and F=Frameset.

Attribute Value Description DTD
alink rgb(x,x,x)
#xxxxxx
colorname
Specifies the color of the active links in the document. Deprecated. Use styles instead. TF
background file_name An image to use as the background. Deprecated. Use styles instead. TF
bgcolor rgb(x,x,x)
#xxxxxx
colorname
The background color of the document. Deprecated. Use styles instead. TF
link rgb(x,x,x)
#xxxxxx
colorname
Specifies the color of all the links in the document. Deprecated. Use styles instead. TF
text rgb(x,x,x)
#xxxxxx
colorname
Specifies the color of the text in the document. Deprecated. Use styles instead. TF
vlink rgb(x,x,x)
#xxxxxx
colorname
Specifies the color of the visited links in the document. Deprecated. Use styles instead. TF

Standard Attributes

id, class, title, style, dir, lang, xml:lang

For a full description, go to Standard Attributes.

Event Attributes

onload, onunload, onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup

For a full description, go to Event Attributes.