|
|
|||||||||
|
</html>
Save the listing above as first.html then using Windows Explorer, find the file you just saved and double click on it. Your web browser will open up, load the html file and display it. You should see the title bar of the browser says ‘My first web page’ and the main window has the text ‘This is the main part of the web page and can contain one or more lines’.
Let’s go through this step by step. First there is the <html> tag. Most tags have a start tag and an end tag to indicate the beginning and the end of the text they effect. You can see the last line is </html> and everything between these two should be valid HTML code. These tags mark the start and end of the html document. Whenever tags work as a start and end tag, the end one is usually the same as the start but with a forward slash at the beginning e.g. <br> and </br>
Going back to the top, after the <html> tag is the <head> tag. This should always be after the <html> tag and before the <body> tag and is used to define the header for the document. It does little in itself but is effectively a container for the next item which is <title>. This tag is used to set the title of the window and is also the text that gets displayed and stored if you save the page to your favourites or bookmarks. Any text after the <title> is considered to be the title until the browser encounters a </title>. The next line contains </head> which indicates you have finished describing the header.
Now we start on the page itself. The main part of a web page is called the body and this is described between the <body> and tags. Any text between these will be displayed on the browser as a web page. The example above only has plain text but you can include extra tags with further formatting information. We’ll be looking at that later. For now, it is worth noting that even though our listing has two lines of body text, it gets interpreted as one long line by the browser. This is to allow for the fact that a browser can be any width with the text on the page adjusting itself to fit. You can force separate lines but we’ll be saving that for part 2 when we look at text formatting in more detail.
|
|