Creating an HTML Document - HTML

Creating an HTML document is relatively easy. One of the nice properties of HTML is it is just text. The content is text and the tags are text. As a result, you can write your HTML in any text editor. If you are running any variety of Windows, you can use Notepad, which comes installed with Windows. If you have a Mac on your desk, you can use SimpleText. If you work in UNIX, you can use emacs, vi, jove, pico, or whatever you normally use to edit text. Essentially, any text editor or editor capable of producing text-only documents can be used to create HTML documents.

Writing HTML

What else do you need to know to write your HTML? Presumably, by now, you know the following:

  • What your purpose is (at least generally)
  • You need to write your content from your focused message
  • You mark up your content with HTML tags
  • You can write your page with a text editor that is already installed on your computer Obviously, you need to know the elements. But before discussing those, here are a few guidelines about how you should and shouldn’t use HTML.

Name your files with a Web-friendly extension
When saving an HTML file you should always give it a .html or .htm extension. (The former, .html, is generally preferred.) This correctly identifies the file as having HTML content so that Web browsers and servers correctly handle it. Other Web files have their own extensions—for example, most PHP files use .php, graphic files use .jpg, .gif, or .png, and so on. This book suggests appropriate extension(s) as each technology is discussed.

Format your text

If you are already writing HTML pages, you may need to break your bad habits. You probably already think in terms of getting the browser to make your page look the right way. And you use HTML to make it do this. You may even use goofy conventions such as 1-pixel-wide clear image files (usually GIFs) and stretch them to indent your paragraphs.
With HTML 4, you needn’t out-maneuver the browser. Browsers that support the HTML 4 standards display your pages as you define them—no more of that arrogant printer stuff! And fortunately, with HTML 4, you can define the way you want your pages to look outside of the content, so your HTML won’t be all cluttered with tags.

Structure your document

So, if you are not supposed to use HTML to format your pages, how should you use HTML? HTML defines your document’s structure. Then, outside the main body of the document (or even in a separate file, if you prefer), you define the appearance of each element of the structure (just like the publisher and the printer in the previous example).

With few exceptions, you want all your paragraphs to be formatted the same— uniform margins, indents, fonts, spacing between lines, and color. So, within the main body of your document, you type your text for each paragraph and mark up your document to indicate where each paragraph begins and ends. Then, in a separate location and only once, you define how you want all your paragraphs to look.

Existing ways to override this universal definition are discussed later. The most important concept to remember—and this is a big change for you if you’ve already been writing HTML 3.2 or earlier versions—is that the HTML only defines the structure of your document. The formatting of your document is handled separately. What is so great about this? First, your text doesn’t get all cluttered up with tags.

And second, you can define the look for your entire site in one place. You simply have every page in the site (even if some pages in your site are being written by people you have never met) point to the style sheet (the place where you put all those style definitions).

Don’t I Need a Web Server?
Later chapters will show you how to upload your documents to a dedicated and public Web server where others can see them. In the meantime, you can simply use your computer’s hard drive and a local browser to dabble privately with HTML.


All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

HTML Topics