===========================================================================
Today on The World Vol. 4 #139 Friday, May 29, 1998
===========================================================================
Here's the beginning of a long series of articles on how to write HTML
(for designing Web pages from scratch and understanding exactly what's
happening, something you don't usually get a feel for if you rely on a
drag-and-drop editing program like PageMill or FrontPage.) This first
segment will be the longest. Subsequent installments will discuss one
or two HTML elements in detail, working up to the hard things like
tables and frames.
By the way, those of you who are reading this with programs that "render"
embedded HTML tags (such as Eudora, Netscape Communicator, Internet Explorer)
may run into the problem of your program rendering the example HTML tags
in these tutorials. If it seems like words and examples are missing from
these tutorials, or if it has strangely garbled formatting, then you should
try (a) disabling the rendering of HTML in your program, or (b) save these
tutorials to disk and look at them with a text editor (such as WordPad or
SimpleText).
---------------------------------------------------------------------------
In other news related to our Web site:
The HPA (Home Page Alone) tutorial posted to Today On The World last
week is now on the Web with our other Web page creation help files:
http://world.std.com/help/web/index.shtml
(This series of HTML tutorials will eventually join it.)
Also, we've added or updated about 200 FAQs in our collection of our
favorite FAQs from Usenet:
http://world.std.com/help/faqs.html#OTHER
(It's still a little spotty in places -- for instance, we're missing
a few pieces of the Babylon 5 FAQ -- but I'll patch up some of the holes
when I have time.)
(kibo)
---------------------------------------------------------------------------
HTML TUTORIAL -- CHAPTER 1: FUNDAMENTAL TAGS
After completing the first few parts of this tutorial, you will be able
to craft your own pages from scratch with no special tools. (This is a
"learn by doing" tutorial, not a reference manual.) I highly recommend
doing each chapter on a different day, as this tutorial covers a lot of
ground very quickly, and you'll want to let it sink in. Chapter 1 will
introduce you to the structure of HTML, and you'll be "marking up"
(formatting) text. In fact, by the end of this chapter, you'll be able
to create simple pages of text (you won't learn how to make links or
include pictures until a subsequent chapter, but Chapter 1 does tell you
how to put text on a page.)
CHAPTER 1 - FUNDAMENTAL TAGS
1.1 What's HTML?
HTML (HyperText Markup Language) is a programming language used to
format Web pages. Yes, a programming language, like BASIC, FORTRAN,
Pascal, and C. Wait, come back here! HTML is just about the simplest
computer language ever devised. (And Web browsers are sometimes
tolerant of errors--they attempt to show the text on your page no matter
how garbled your HTML is.) There is no real "programming" in HTML--all
you have to do is to embed little "tags" (they look like The rain in Spain falls mainly on the plain.
This is
a test
of the
Emergency Broadcast System, this is
only a
test.
If this were
an actual
emergency,
we wouldn't
use the Web
to tell
you
about it.
or
Hello, World!
) and ends with a matching tag (
and
...
marks a paragraph of regular text.kind and the
and
...
and the beginning of another (of any sort) there's some extra space. In other words, if you put...
around each paragraph of text and...
pairs (around the oddly-formatted text) to...and see what happens.
indicates a section of preformatted text, in which the browser should not alter the spacing any more than is necessary to fit it in the window. A fixed-width (typewriter) font is used instead of the text font. If you had a bus schedule with carefully-aligned columns of numbers and wanted to ensure the spacing would not change, you could use. (I like to think ofas being a kind of paragraph, even though it can have multiple paragraphs inside it.) So now you know nine kinds of text blocks: MAKING PARAGRAPHS...
Level 1 (huge) heading through...
Level 6 (tiny) heading...
Paragraph of text...A block of pre-formatted typewriter text (this is not really a paragraph per se, as it can span several paragraphs.) My advice is to enclose each part of your text in one and only one of these. You can't overlap or nest these pairs of tags: you can't put ainside
...
or vice versa. These tags serve similar purposes--to describe the paragraph structure of your page--and so no two of them can apply at the same time. 1.5 Styling text However, there are other pairs of tags which can be nested inside...
. Try adding this sentence to mypage.html after the "Emergency Broadcast" paragraph:This sentence has a lot of italics but only one boldface word in it.
Now view it in the browser. You've probably guessed what will happen: ... make italics and ... make boldface. (Of course, under some circumstances, you can't see those styles--such as in the program lynx--but they'll be indicated somehow.) Notice that we begin, then , then , and then we end , ,
in reverse order: the tags are nested. I like to think of it like so:.................................................
............................... .... If we had used:This sentence has a lot of italics but only one boldface word in it.
We would be overlapping the...
pair with ...:.............................................
................................... .... The page would still be viewable, but it would be "wrong"--it might look okay, it might not. (It might apply the wrong formatting to text which follows that sentence. If you try this experiment, be sure to fix it so it won't affect the following examples.) HTML is pretty forgiving, but it's best to follow the rules. (Some browser programs are more lenient than others about working with bad HTML.) We can nest ... and ... inside...
. What would happen if we put ... or ... inside...
? Let's try it by adding this to our page:This heading has bold, italic, and typewriter styles in it. This may or may not work.
What would happen now would depend on which browser you're using and how you've configured it. You see, most browsers always make...
bold. So do you expect ... to do anything? (It probably didn't.) The various style tags we used in that header may have worked fine, sort of worked, or not worked, depending on circumstances. Essentially, we shouldn't be trying to change styles inside; in HTML,
is what's called a "logical style". It means that the browser should be displaying things in a special way (large bold print or something else, depending on the browser); if we try to turn bold on and off inside
, we're giving the browser conflicting information. So and so on should be used only inside
paragraphs, not
through
or
paragraphs, which already have special formatting. STYLING TEXT ... Boldface; use only inside...
... Italic; use only inside...
... Underline; use only inside...
... Typewriter; use only inside...
(I haven't discussed and because you probably won't use them often; one's an underline and the other's typewriter text. Most browsers underline links, so don't underline text or you'll confuse people. is different frombecausemakes an entire paragraph of unformatted text, while just changes fonts within the paragraph.) 1.6 Aligning text So now you know how to make paragraphs of text and headings, and how to put bold and italic into the text. What if you want to center something? The paragraph tags we introduced before, such asand
, can take optional parameters to control how they're formatted. Try adding these lines to mypage.html:
This is a plain old heading.
This is a centered heading.
This is a right heading.
This is a plain paragraph.
This is a centered paragraph.
Notice the syntax to center something:, with the optional ALIGN="CENTER" inside the tag. (Again, it can be in capitals or lowercase; it doesn't matter.) There are various other options you can include in and
, but ALIGN= is the most important to learn (all browsers can understand it, unlike some others made up by particular software companies.) If you leave out ALIGN=, you get the default value (ALIGN="LEFT"). Note 1: You may often see other tags,
) add the following tag:... used to center sections of a document. This is not a standard tag--it was invented by Netscape.will not work in some other browsers. Use . Note 2: Some older browsers will not center headings; they may come out with left alignment. Modern browsers can center headings, and all can center text with ALIGN="CENTER". Note 3: Some people type
instead of
. This works most of the time, but there are a few tags whose options must be in quotes. I suggest making a habit of putting quotes after every equal sign. ALIGNING TEXT (here "
or" means one of or
through
)
... Left-aligned paragraph... Centered paragraph... Right-aligned paragraph 1.7 Rules, breaks, and blockquotes By now your practice page is an ugly mess of styles, but we don't care. We're having fun making a mess. Let's clean up mypage.html a little. Between the end of one paragraph and the beginning of the next (that is, after a
And then after the last paragraph, paste this in:Yes, we have
And yes, we have no or today--these tags do not come in pairs. They don't make paragraphs and they don't style chunks of text; they just make a thingie and that's it, so there's no "end tag" for them. Take a look at what they do in your browser. Where you added
no bananas
today
!!!
should be a Horizontal Rule (i.e. a stripe across the page.) The paragraph with
s in it should have breaks (old-fashioned carriage returns) in it. (Note that
starts a new line, not a new paragraph.
is useful for making long titles break between the right words and not at the width of the window.
should not be used to end paragraphs (that's !) but is used to break lines without ending the paragraph, or to make a gap between paragraphs. Try this to see it in action:After a long break, I'll be back with my address.
James "Kibo" Parry
One last formatting trick, that was intended for academic papers but is also an easy way to make margins. Paste this in after the last paragraph:
123 Bozo Street
Boston MA 02345This is a long paragraph which should go all the way across the window once or twice or maybe even three times if the window is really narrow. This paragraph goes on and on and on and on. Blah, blah, blah. This paragraph just doesn't quit.
The weird thing to remember aboutThis paragraph is indented to make it stand out a little. It might also be easier to read because it doesn't go all the way across the window. There are other ways to do this, but this is the easiest to do.
Sometimes I like to do the whole page with "BLOCKQUOTE" tags around all the text to make margins. "BLOCKQUOTE" is one of the few tags you can nest inside itself. I suggest putting the "BLOCKQUOTE"s outside the "P"..."/P"s.
is that it's not a kind of paragraph like,
, and, but that it goes around one or more paragraphs, and that you can have more than one of them active at a time (by nesting
s inside each other.) You should turn offbefore using
or anything centered, as some browsers will misalign centered things whenis on. LAYOUT
Break lines within paragraphs, or make extra space between paragraphs
Horizontal rule
Horizontal rule x% of the width of the window
Horizontal rule x pixels thick...Indented; goes around one or more...
pairs. You may nest this inside anotherblock. Try changing the horizontal rule in mypage.html to be simultaneously 50% wide and 6 pixels thick by putting both options into your
tag. (Some browsers will draw the rule in black, some will made it look transparent and shaded. There is no way to change its color in all browsers, although some have non-standard options for this.) 1.8 HTML document structure Soon this chapter will be over, but first I will keep my promise to explain the other tags in the skeletal HTML page we started with:My Page. The whole document is enclosed by ... to indicate where everything starts and ends. They should be the very first and last tags. Inside ..., it's divided into two sections: ... and .... The section contains information about your document--it must contain a... with the name of the document, and in a future installment you'll see how to put other "metadata" there to identify the document to search engines. The important thing is, don't put extra stuff in .... Your page's text goes in .... The lines which say are comments, and can say whatever you want (or in this example, whatever I want.) I strongly suggest you leave notes to yourself there so that in a few months you'll know what you were thinking when you wrote your HTML. These comments are invisible, except to people who use the "View Source" command (which lets them see your HTML tags just like in your text editor.) For fun, go to other people's pages and do "View Source"; this is a common way of learning HTML. (Of course, much of the HTML you'll see was written by people who don't know what they're doing, so don't go copying other people's tags--you'll know more than they do after a few more chapters.) HTML STRUCTURE ... goes around the entire document ... goes around the top of the document ... the rest of the document, where your text goes... the page's title, usually shown at the top of the window (required to be in ...) a comment, for leaving invisible notes to yourself. 1.9 Final thoughts There are many different philosophies regarding what is "right" or "wrong" in HTML, because most Web browsers can still view pages that deviate from the standards. For instance, many people useat the start of a paragraph but not
at the end, or forget to put in ..., and things usually look okay. But if you're new to HTML (or even if you aren't!) I strongly recommend following the rules I give here. (If you don't like my rules, follow the rules of a different tutorial, or read the official W3C HTML standards, but at least follow somebody's recommendations.) Other people's tutorials will have different recommendations, and if they differ with mine, it does not mean that either is "wrong", just that Web designers (and tutorial authors) have different approaches to making Web pages that work well. (Why don't we all just follow the official W3C standards? Because they're often hard to understand, or something we need to bend the rules to achieve an effect we need, and most importantly, because Netscape and Microsoft don't always follow the W3C standard!) That's all for our first installment. In the following chapters I'll be discussing images, colors, backgrounds and everyone's favorite... links. Until then, you should go browsing and look at how other people are using the tags I've already discussed, and if you feel up to it, make a page of HTML with some text on it (a short story, your biography, whatever) and add some tags to make it look pretty. (Start with the mypage.html skeleton shown above.) (kibo) ========================================================================== [] Send suggestions for tips & URLs to today@world.std.com. We're also collecting links for our Web pages at eyeguy@world.std.com. [] To contact CUSTOMER SUPPORT, send mail to support@world.std.com or call 617-739-0202. [] To subscribe to the "Today" mailing list, send a note saying 'subscribe announcements' to majordomo@world.std.com. Subscriptions to this mailing list are open to World customers only. [] Mmm, Beefy! [] Today on The World is (C) Copyright 1998 by Software Tool & Die. Its contents may freely be redistributed as long as credit is given.