Xah Lee, 2009-09-29
This page gives a very basic, practical introduction to HTML.
HTML is a very simple markup language. Here's a example. Save the following text in a file, name it 〔sample.html〕, then open the file in a browser.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Sample HTML</title> </head> <body> <h1>Sample HTML</h1> <p>Earth is round!</p> </body> </html>
Basically, text are enclosed by tags. For example, in the above,
the <html> and </html> wraps around the whole file indicating that the whole file is a html file.
The <head> and </head> contains some meta info about the file. The
<title>…</title> gives the title of the file. What's inbetween <body> and </body> are the content of the file.
The <h1>…</h1> is the header of the content. The <p> is a paragraph.
Each of the <…> is called a tag.
HTML is extremely simple. There are hundreds of HTML tutorials. You can try this tutorial: http://www.w3schools.com/html/html_intro.asp. For some history and technical detail, see: HTML.
We assume you have gone thru the above tutorial or know the basics of HTML. If you plan to do javascripting and advanced css, you must know HTML well.
There are many versions of html and xhtml, and it is really a mess.
If you are creating new pages, not maintaining old websites, i recommend HTML 4. Put the following line at the beginning of your file.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
This line, basically declares the version of html used. It is called Document Type Definition (DTD).
The above DTD is for HTML 4 strict. It is supported in all major browsers released after 2000.
There are 3 sub-versions of html 4. They are: transitional, strict, and frameset.
The transitional version is most widely used. They provide some backward compatibility with HTML 3 or earlier. The “strict” is more strict version, and does not support some appearance tags of html 3, such as <font>.
Appearance markup should use
CSS instead.
The “frameset” version is for pages where you want split windows.
See: HTML Frameset Tutorial.
If you must go for more compatibility, i recommend HTML 4 Transitional. If you want to use html 4 transitional, put this line in the beginning of your file:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">blog comments powered by Disqus