The first page

The initial incantation so the page can be read

The very first thing to be written in an HTML file is a declaration of the document type. Here you tell the browser how to read the rest of the file, i.e. which rules to follow. As developer you have two options here: HTML 4.01 and HTML 5.

HTML 4.01 is the standard currently in force, which all browsers understand. HTML 5 is the new standard, which W3C is developing. When it will be fully ready is still unclear, but new browser can already use several of the new tags, and older browsers will just ignore the tags it does not recognize and treat the rest as if it was HTML 4.01. Beneath is the declarations for both HTML 4.01 and HTML 5, which can be used as the developer see fit. The recommendation from here, though, is to use HTML 5.

HTML 5 declaration
HTML 5 only has one setting, which makes HTML 5 a lot easier to work with than HTML 4.01:


HTML 4.01 declarations
If you really want to use TML 4.01, there is three types of declarations: strict, transitional and frameset, and the codes for the three HTML version 4 declarations (the current standard), are:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "">

The difference between the three declarations is mostly how closely the browser should stick to the code. Basically transitional and frameset allows the browser to make interpretations and guesses, if the coding is not correct. In general using strict is recommended, as it gives the lowest amount of problems across the various browsers.

It may be an alluring thought to have the browser fix the errors in the programming, but based on experience, it is a very bad idea. The difference between browsers means that letting your browser be creative will produce more problems than it solves. On occasion you may need to use commands or parameters which requires transitional or frameset drclarations to make the page work right, but as a general rule, strict is preferable when it comes to HTML 4.

The HTML structure

The next part to be added is



These are tags that will be addressed on other pages. The text, as it looks now, tells that what is coming now is HTML, and that HTML contains a section called HEAD, and after that a section called BODY. HEAD is where you write things like the page title which is seen in the windows bar and the browser tabs, if they are shown. BODY is the page content, that is shown in the browser.

As the page looks now, with DOCTYPE, HTML, HEAD and BODY, we have a blank page, which can be read by a browser.

The code with DOCTYPE, HTML, HEAD and BODY must be on all pages on the site!

Naming the first file

The first file being read, when you enter a site, is the file named index.htm. If this does not exist, the browser will look for a file named default.htm. If one of these files aren't found, an error message will appear in the browser, that it can't find the site. The names index and default have to be lowercase, otherwise the browsers can't read them on their own. The explanation is, that the servers are case sensitive, i.e. uppercase (capitals) and lowercase are two different letters, so Index.htm and index.htm are two different files, and the browser only look for index.htm.

Obviously, there is a workaround for the name of the first file. There is a file named .htaccess, where you can point to another file to be opened. It is, however, one of those files, where you have to be a little skilled before editing. A common spelling error can make the entire site stop working.

Sites automatically taking the visitor to an opening page, e.g. in your own language, is not another page than index or default being opened first. A small program, detecting where in the World you are placed, on the first page being opened, will use the information to redirect to another page instead.