
HTML Tutorial1) IntroductionTo create a web page, you first need to create a simple text file. Rename the text file and change the extension from txt to html (for instance, rename from XXX.txt to XXX.html). Opening the file with a text editor (like wordpad or emacs) will allow you to edit the source code defining how your web page should be built. Opening the file with a web browser (like Internet Explorer or Firefox) will allow you to see the actual web page resulting from the source code you are writting.The HTML language is defined with some tags. Anything located in between the opening tag <TAG> and the closing tag </TAG> will be displayed with the properties of the tag. <TAG>My text</TAG>Some tags also accept optional parameters which can be defined inside the body of the opening tag : <TAG PARAM1="param1Value" PARAM2="blabla" PARAM3="otherValue">My text</TAG>Finally, some tags just have a local action and do not really activate a specific formatting for what follows. Those consequently do not explicitely need to be matched by their closing tag. Some text<TAG>Some more text 2) Basic StructureThe most basic squeleton defining the structure of a web page would read :
The tags <HTML> and </HTML> define the begining and the end of your source code which should obviously be placed in between them. The source code is then split in 2 parts :
Now try to replace <BODY> with <BODY BGCOLOR="blue" TEXT="red">, save your source code, and reload the page in your web browser. You can then see the effect of the additional parameters provided to the tag <BODY> which define the color of the background (BGCOLOR) and the color of the text (TEXT). To get more familiar with the web page you've just created, you can try to :
Note that you will need to save the source code and reload the web page in your browser to see the effect of the modifications you made to the source code. Now let's study what you can put in between the <BODY> and </BODY> of your web page. 3) Text Formatting TagsThe way your source code is arranged doesn't really matter, leaving blank spaces and inserting empty lines will just make your source code easier to read and to understand for the programmer (that's you !), but won't change anything in the way your final web page will look like. For instance :
In order to make the text in the final web page start to a new line, you must consequently use the line breaker tag <BR>. This tag just breaks the current flow of the text and starts a new line where inserted in the source code, but doesn't actually define how the following text should be formatted. Consequently, this tag doesn't require to be matched by its corresponding closing tag </BR>. For instance :
Now let's look at some tags that will activate a specific formatting which will be applied to the text following them. Since those tags "activate" a formatting, the opening tag needs to be matched by its corresponding closing tag in order to deactivate the formatting after being done using it. For instance, the tag <U> displays the text underlined.
Some other useful tags are :
Now, you can try combining some of those tags together in the body of your web page, for instance in bold and in italic :
You can also try to interleave them :
4) Hyperlink TagCreating a hyperlink (to another page for instance) is done by using the tag :<A HREF="targetOfTheLink">where to click to follow the link</A> The link can be relative to the current directory, for instance pointing to a file in a subdirectory of where the page is located :
The link can also be absolute, meaning that it will contain the whole path, starting from the root directory :
The link can also point to another web page, either local (proceed as for the first case, replacing "Data/document.txt" with "NameOfTheFolder/otherWebPage.html"), or on the web, as in the following example :
5) Other Useful TagsTo insert an image in your page, use :
You can also use an image as the link to follow a hyperlink :
Unordered lists use the tags <UL> </UL> which delimit the list. Inside the list, each item is specified preceeded by the tag <LI> :
Tables are defined by the tags <TABLE> </TABLE>. The tags <TR> </TR> define a new row (vertically) whithin the table, while the tags <TD> </TD> define a new cell (horizontally) whithin the row :
6) Other ResourcesIf you need a "more in depth" tutorial, I guess googling for it will probably lead you to what you are looking for. For someone slightly familiar with HTML, I would recommend The Bare Bones Guide to HTML (also available in other languages) which gives a clear and concise list of the different tags and their usage.Happy coding ! |