===========================================================================
Today on The World Vol. 4 #151 Wednesday, June 10, 1998
===========================================================================
Continuing the HTML tutorial series... this section discusses general
topics regarding making "good" HTML. At this point you know all you
need to make Web pages with styled text, pictures, colors, and links.
In the future you'll read about "advanced" topics such as tables and
frames and stuff, but for now you know the nuts & bolts. So it's time
to take a break and talk about tuning up any pages you've started
building with what you know. (And if you haven't started on your own
Web site yet, go ahead and do so!)
---------------------------------------------------------------------------
HTML TUTORIAL -- CHAPTER 6 -- TIPS & TOOLS
6.1 View Source!
Most of us learn HTML tricks by finding interesting Web pages and using
the "View Source" command in our Web browser (it may be a button or a
drop menu item, or you can just save the page's source to disk and
view it in your text editor.) But keep in mind that if you copy
anyone else's code you're copying their mistakes (and if you don't
believe me that other people's Web pages aren't coded as well as
they could be, try running their pages through a validator --
see next topic.)
6.2 Validate!
A validation program is a tool that checks your HTML for what it
thinks are mistakes (common slip-ups, unknown [misspelled] tags,
deviations from the W3C standard, etc.) These are very useful tools
(I can't stress this enough) for making sure you didn't do something
silly like spell Potatoes are your friend. is not allowed within Hello, World!
I Like Potatoes
"
when what is really wrong is on Line 1: your
is missing.
So if you see a strange error, chances are the problem is either
on that line or else you forgot to turn off something above it.
It's very important to validate because some browsers (Netscape's
in particular) are lax about enforcing W3C standards. These
browsers will do their best to make your code "work" no matter
how scrambled it is. That's great for the people using those
browsers, but for the people who use browsers which display what
you actually wrote, bugs and all, if you only test your code
with a lax browser then other people may see a defective page.
Which brings us to...
6.3 Test!
Check your page with EVERY BROWSER YOU CAN. This means running
not just Netscape Navigator and Internet Explorer on your
computer, but if you can stand it, run older and newer versions.
Make the window wider and narrower. Quit your browser and
switch from 256 color mode to millions of colors (or vice versa)
and test again. Be sure to try both the Windows and Mac
versions of the same browsers (yes, they have different bugs
and quirks) if you can (every version of every browser for
every operating system is a little different.)
If you can, use "minimalist" browsers such as Mosaic 1.0 or
older versions of AOL or lynx to see what your pages will look
like when viewed in such restricted environments. If your
pages have features that will not work in those cases, you'll
need to provide alternatives (text links below the image map;
alt text for all the images; a "no-frames" version).
You cannot just say "You have to buy a Macintosh, install
Netscape Navigator 4.04a, enable JavaScript, and upgrade your
graphics card 1600x1200 to look at my page." People will simply
visit your site, see a broken-looking page in their favorite
browser, and go away. Well-designed Web pages should be viewable
by people who have arbitrary browsers and setups.
(Obviously if you need to use a bleeding-edge technology like
a Java applet there's no way a person with, say, a WebTV,
will be able to see it, but the goal is to not restrict
what kinds of browser can view your site unless you have
a good reason. "Plain" pages -- text, pictures, links --
should be viewable under the widest variety of circumstances.)
6.4 Indent!
If all else fails and you can't figure out why your page is coming
out askew in Browser X but not Browser Y, you probably have some
subtle error in your HTML such as improperly nested tags (or are
missing something like to turn something off.)
Try rearranging your code so that every tag is on a separate line,
then indent a few spaces for each nested item:
...because in the latter example you can read downwards and see thatHello, World!
doesn't line up with
so you know something's mis-matched. Some text editors can automatically format your document this way (as well as doing the reverse -- stripping out all the extra spaces to make the page download faster.) When in doubt, remember: Most HTML tags come in pairs, except for a few (...
,...,
...
. Don't putinside...
. A few things DO go outside the text containers:
if you want a gap,
,, etc. But all the visible text (and the tags that "style" it, such as , , , etc.) go inside the text containers. (We'll coverand
in future installments.) 6.6 Too Wide! How large can you make something and have it fit in someone else's window? You don't know. Their monitor might display 640x480 or 1600x1200, and you have no way to tell from your end, and furthermore, they can make the window wider or narrower at will. (Also their browser will probably need to reserve some space at the edges for the scroll bars, menus, and icons, making the exact amount of space available even harder to estimate.) A good rule of thumb is that you should keep your images (or tables) under 540 pixels wide if possible. Why? 1.) When printing a Web page, and the images are considered 72 pixels per inch, you only have about 7.5 inches (540 pixels) between the margins on U.S. paper. (It's about 520 pixels for the rest of the world, by the way.) 2.) 640x480 is the smallest screen size available on any modern computer (old EGA IBM PCs and early nine-inch Macs excepted, but we'll ignore those 'cause they're unlikely to be on the net these days) and yes, people do choose to use 640x480 (because they like large print.) Or some people's computers came set for 640x480 and they've never learned how to change it. Or they have an old monitor that only does 640x480. In any case, the largest size you can guarantee that any modern computer will display is 640 pixels across (minus a bunch for the stuff on the sides of the window.) Note that some versions of Netscape Navigator default to 480-pixel-wide windows on 640x480 screens. 3.) WebTVs, which after usually used with TV sets, are limited to 544 pixels across. And they cannot scroll horizontally, only vertically. So pick a number (I like 520, myself) based on how many people you want to be able to see your page. (My 520 makes my pages go off the edges of things like 240x320 handheld PDAs, but you gotta draw the line somewhere.) If you don't have any gigantic images, and if you don't specify any width in particular for