corner Tutorial introducing the basics of producing a simple Web page, in HTML, elements and tags  corner
space design

Design

 

 

corner

2. First Simple Web Page. HTML Elements and Tags

corner
HTML Tutorial

    bookmark W3C Validation HTML 4.01 image

Web Design

Page Contents - First Simple Web Page

Lesson Introduction  
Required HTML Elements <HTML> <HEAD> <TITLE> <BODY>
  <HEAD>
  <TITLE>
  <BODY>
HTML Tags  
Adding some Text Exercise 1. My First Web Page
Saving your work

index.html
File names

View your page in a Web browser  
Line Breaks <BR>
  <P>
  <HR>
  Exercise 2. Line Break experimentation
Test Exercise 3. Page 1
Read panel Web Sites, Web pages, Links (Top right)

First Simple Web Page - Introduction

In this your first true HTML tutorial you will learn:

  1. How to write the HTML code to produce 2 very simple web pages named:
    index.html
    page1.htm
  2. The use of HTML elements and attributes.
  3. How this code consists of HTML tags and plain text
  4. How to save the HTML files to a folder named my-web-pages on your hard drive.
  5. How to view those pages in your browser.
  6. Tutorial 7 shows you 'How to link pages together', so that the viewer can easily view other pages.
  7. Tutorials 3 - 6 show you 'How to improve the look of your pages'

You will find out how producing you first web page is very gratifying.

John McGuinn

space

 

 

space
Search this site for a word or phrase. Place phrases inside "double quotes"

Buy Domains from 1&1 and Save Money!

Buy web hosting from 1&1- Get More for Less Money

 

 

Required HTML Elements

All web pages require the following code, in the form of HTML tags, which produces a blank web page.

<HTML>

     <HEAD>
          <TITLE></TITLE>
     </HEAD>

    <BODY>
    </BODY>
            
</HTML>

HTML Element Tags

  • Basically HTML tags are the programming code that states how your page should be displayed by a web browser.
    • A few additional Meta tags are required to
      • Set up a basic web page, as above
      • To promote your site with search engines.
  • HTML tags are enclosed in a pair of less than and greater than brackets < > these brackets are known as the open delimiter and close delimiter respectively.
  • Tags are not not case sensitive, so the body tag can be written <BODY> <body> or <Body>.
    • In this tutorial I will write all tags in uppercase.
    • Some HTML editors may require tags to be in a particular case. However it is best to keep all your tags uniform, this helps with readability of the code.
  • Most HTML commands require both a start tag e.g. <BODY> and
    a corresponding end tag, </BODY>.
    • Note how the end tag, is the same as the start tag, with the inclusion of a / before the tag name.
  • There are a few tags that do not have a end tag,. E.g. <BR> (Break, starts a new line)
  • Tags are not displayed by the browser.
  • Some tags are not supported by some browsers, some are supported differently, hence the different appearance of web pages in different browsers.
  • When writing your page you can indent lines to make the your code more readable.
    • The indentation is not required but does help to ensure that as you insert additional commands and text it is placed into the correct position.
    • Indentation is helpful tables and especially with nested tables.
  • Blank lines called white space can be introduced to make your code easier to understand.
    • This "white space" is ignored by the browser.
    • It increases the size of a file, slightly lengthening download time.
    • It can always be trimmed later, before uploading to the web, either manually or automatically by some editors and HTML checker programs. Thus reducing the file size.
  • Comments can also be placed within your code if required. Comments are ignored by the browser. <!--This is a a comment -->
  • Take particular note of how the tags are paired, end tags are in reverse order to start tags
    • <HEAD><TITLE></TITLE></HEAD> is correct.
    • <HEAD><TITLE></HEAD></TITLE> is wrong

The table below displays information about the tags.

End tag column, states if an end tag is required or not. I recommend that where this is optional you should place an end tag. Opt = Optional. Req. = Required. No = Don't use.
The last column contains Attributes which are introduced in the next tutorial.

Element Description / Comments End Tag Attributes
<HTML> The HTML element is the container for the entire document. Ensure that <HTML> is the first command, and end tag if used the last one. Opt title,version
<HEAD> The HEAD element encloses the TITLE element as shown.
Other elements that can be contained in head are the BASE ISINDEX LINK META SCRIPT and STYLE elements
Opt class,id,profile,title
TITLE> This element describes the content of your page, appears in the browser title bar, and used by many search engines. Only 1 title allowed, must be within the HEAD element. Limit to 64 characters. Req.  
<BODY> The main part of your page goes between the body tags Opt alink, background, bgcolor, bgproperties, bottommargin, leftmargin, link,

Top.

 

Adding some Text

 

In this HTML tutorial you shortly will work through an exercise that will produce your first web page that you will save onto your hard drive, then view it with your web browser. Later in tutorial 9, when you have gained knowledge to produce a decent web page or site, you will learn how to upload a site onto the WWW

Exercise 1 My First Web Page

Step 1. Requirements:

At this stage in this HTML tutorial you only need to use Windows notepad, or the equivalent simple text edit or on a Mac as your HTML editor, and a browser such as IE explorer. To refresh your memory on Web Browsers see Tutorial 1 - Web Browsers.

I believe that this is the best way to learn the code and layout of HTML.

If you have a more sophisticated HTML editor you can use this. These editors, depending on the editor, may have editing windows such as

  • Code view, this is a view similar to that produced by notepad, but enhanced, to make it easier to read the code. Achieved with
    • The text in various colours
    • Automatic code indentation
    • The use of bold or italic text.
  • WYSIWYG (What you see is what you get), this means that the appearance of the page in the editor looks similar to what a browser will produce.
  • Tag view. Similar to Code view but graphic icons are used for all the tags.

If you use one of these editors you can use the code page view, the same as using notepad. Or if you use one of the other views that will automatically create the code for you, always switch to the code view to see how changes effect the code produced.

In order to learn the code ensure that you look at the code produced.

It may be possible to have 2 windows on view at the same time.

Please note that automatic processes sometimes produces additional code that is not actually required.

Step 2. Preparation.

  1. Create a folder (Directory) named my-web-pages, using Windows Explorer, or the equivalent on a Mac. Take a note of exactly where you save it I.e. its path. I suggest that the best place would be in the Root directory so the final result would be C:/my-web-pages
  2. In order to carry out Step 4 below, you require at least 1 web browser installed on your computer. To refresh your memory on Web Browsers see Tutorial 1 - Web Browsers.

Besides reading these step, Dreamweaver 4 users Dreamweaver click here for additional instructions.

Because the above code only produces a blank web page you will add

  • My First Web Page between the title tags
  • The words Hello World between the body tags, as below. Note that no additional tags are required.
<HTML>
     <HEAD> 
             <TITLE>My First Web Page</TITLE>
     </HEAD>
     <BODY>Hello World
     </BODY> 
</HTML>

Step 3. Enter the Code.

Depending on your preferred method of learning, you can copy (ctrl c) and paste (ctrl v) the above code into your HTML Editor or type it in. You will possibly remember better by typing it in, this is also better if your keyboard skills need improving.

Top.

Step 4. Saving your page

Save this file using the Save as... option as index.html to the folder my-web-pages you created in step one. After you have saved the file, close notepad.

Click here to find out why index.htm it is a special file name, also read the panel above, File names

Top.

Step 5. View your page in a Web browser.

To do this open the file index.htm in the folder my-web-pages in your browser. You will find detailed instructions on how to do this with Microsoft Internet Explorer, the most popular web browser.

Note: Many of the purpose built HTML editors have a button that you can click that automatically performs this step.

  • Open up Microsoft Internet Explorer.
  • Click File on the menu bar of the browser.
  • Click on Open, The Open Dialog box shown left will appear.

Open Dialog

  • Click on the Browse button in the small popup window.

MS IE

  • Use the down icon to the right of the Look in: pane, to open up the list to select the drive where you saved your file.
  • In the large pane below it find and select the folder my-web-pages
  • Then select the file index.htm and double click on it. This will open up your web page in the browser.

 

space
space

 

Link to us

I hope that you have found this site useful. Please help by spreading the word and by linking to us from your own website.

 

 

Index.html

index.html has a special meaning for Web browsers, in that it is one of pages that a browser will look for, even if the page is not typed into the browser.

List of special file names

 

Web Sites

Web sites consist of one or more Web pages.

Web Pages

Pages contain the text and graphics and HTML code that lets the browser know how to display the page.

Pages usually contain links that allows the user to easily move or navigate around the page, site or go to a different site.

Links

You will learn how to code navigational links in tutorial 07 linking.

 

 

File Names

In the early tutorials you are told the file name you should use. In later tutorials you will be told to use a file name that you can select with your own web site in mind.

The file names that you give to your web pages, graphic files, and downloadable files should follow these simple recommendations.

Do not include spaces.

Spaces can be replaced by the minus sign -, or the underscore _ if required.

On some web servers (Your host) it is better to use lower case only. An exceptions to this are
Default.htm
Index.html

As a beginner always use the extensions .htm or html. You will learn about more specialised extensions later.

WRONG Examples

my first page.htm
MyFirstPage.htm

CORRECT Examples:

my-first-page.htm

my_first_page.htm

 

Planning your Site

You may already have your proposed site already planned out If not you can start doing it now so that you can start to put it together as you continue with these tutorials.

Write down the subject that each page will contain

For one of your pages write down the heading the Headings and Sub headings.

You will use some of this information when do the test at the end of this lesson.

 

 

  • Click OK Rearrange the 2 windows so you can view them both, you should be able to give them more room than the followingNotepad

Note the following:

  • In Notepad
    • The filename Index.html in the title bar
  • In the Browser
    • The title My First Web Page that was enclosed within the Title Tags
  • Hello World in the top left of the window. By default this should be black text on a white background

Step 6. Edit your code.

  • In note pad, click immediately after the end of the word World.
  • Press the Enter key twice.
  • Type in the word Again.
  • Your code should now look like this
<HTML>
     <HEAD> 
             <TITLE>My First Web Page</TITLE>
     </HEAD>
     <BODY>Hello World

Again
     </BODY> 
</HTML>

Question 1. When displayed in the browser, where do you think the word Again will appear on the page in relation to the words Hello World.

Go to Answer 1

Step 7. Save.

Because the file has already been saved, you can use the Save option, rather than the Save as... option.

Step 8. Refresh the browser.

Click the Refresh button in Internet explorer or the Reload button in Netscape and note the resultant changes.

This process of Amend the code, Save the Notepad file and refresh the browser is fast and almost gives you WYSIWYG results.

If the re-sizing has made the browser window too narrow the effect of word-wrap could place the text on more lines. Widen and narrow the size of the window to observe word-wrap.

You may be surprised that Hello World Again appears on 1 line. Remember what I said about "white space". If you wish to insert more that 1 space between words, or to force text onto a new line it must be coded into the HTML, you will learn how to do this in the next.

 

Top.

Line Breaks

You found out that placing blank lines within the text of your page does actually place a blank line into the browser's displayed page.

The table below shows 3 Elements that place some form of line break into your text.

Element Description / Comments End Tag Attributes
<BR>

The Line Break element places the start of the following text or image onto the next line.

No clear
<P>

Prior to Ver 4, P started as a line break. Now P is a block level element, and defines a paragraph. Inserts a blank line after the paragraph. This cell contains 3 <P>s

If omitted the element ends at the next start block level element start tag.

No other block level element may be nested inside a P element.

Opt align
<HR> The Horizontal rule element. Inserts an horizontal rule (line). E.g.
The colouring, size and position of the horizontal rule can be altered using the attributes, when using recent browsers. The default line being a shaded engraved line.
No

align, color, noshade, size, width

 

<NOBR>

<SPACER>
<WBR>
The following are available but not required by a beginner.
NO BReak element
. Of limited use and should be used with care.
Spacer element. Netscape browser only
Word Break element. Used in conjunction with the NO BReak element
   

Top.

Exercise 2. Line Break experimentation.

Step 1. Edit the previous code to the following.

<HTML>
     <HEAD> 
             <TITLE>My First Web Page</TITLE>
     </HEAD>
     <BODY>
     This<BR>is<P>a</P>line break <HR> experiment 




     </BODY> 
</HTML>

Note

  • How several different tags have been placed on one of the lines.
    • Although this is allowed it makes the code harder to read.
  • How I have left a few lines of white space after experiment.
    • This makes finding the current area I am working at easier to find. For a short file like this it is not required, but in a large file it is a useful tip.

     

Step 2. Save as Page01.htm
Save this code as Page01.htm in the my-web-pages folder.

Step 3. View the result in your browser, because you are using a new name you will have to open the file, rather than use the refresh button. Note the results of the 3 line breaks you have used.

Remove the closing P tag i.e. </P>, save and refresh the browser. Note how you loose a blank line.

Top.

Test

Question 2. Place the following tags into the correct order in order to produce a blank web page
<BODY> </HTML> <HEAD></TITLE> <HTML> <TITLE> </HEAD> </BODY>

Question 3. What is the special file name that will open automatically by a browser.

Question 4. Which opening and end tag combination is used to place a blank line after some text.

Question 5. Which tag places text onto the next line. There is no end-tag,.

Question 6. Which tag draws a line across the screen. Is there a end-tag,.

Check your answers.

Reread sections of this tutorial if you obtained any wrong answers.

To conclude this test you are about to do your own page. Attempt to do as much as possible from memory, only refer to this tutorial if required.

Exercise 3. Page 1.

Before starting this exercise read the 2 panels Web Sites and Planning your Site

The entry into a web site is often by welcome page that is followed by a menu page, or directly into a menu page

The menu page of say a families personal web site may have menu entries such as About me. The family. Our pets. My hobbies. Clicking on one of these links directs the user to the corresponding subject page further into the site.

What you will be doing next is to write about 3 or 4 paragraphs, on some subject of your own choice. This will eventually become a page on your website. But not an Entry page. In the following tutorials you will be continuously adding to and amending this page and the Index.html page you have already saved.

  • Start with a blank notepad.
  • Attempt to write the required code, from memory. See how much you can remember, before looking up the references above.
  • Enter a suitable heading before your text,and a couple of sub headings at suitable places within the text.
    • These should all be entered on separate lines using the <P> and </P> tags.
    • You will learn how to make these stand out from the general text of your page in tutorial 3. Page Appearance
  • Attempt to use the 3 methods of inserting line breaks from memory. Besides 3 or 4 paragraphs you should have a couple of line breaks, and at least 1 line.
  • Save the page as page01.htm If you wish to use a name of your own choice then do so, but you must use the name you have picked in place of page01.htm henceforth.
  • View the page in a browser, correct any errors if required.
  • Make the layout neater.
  • Check the result in different browsers if you have them.

Top.

Answers

Answer 1.
The result is displayed on one line,
Hello World Again.
You will learn that you can not enter more than 1 space between words by typing in additional spaces or line feeds. Additional code is used to state that it must be displayed on a separate line.
You will learn how to do this next.

Return to Question 1.

Answer 2.
The correct order is
<HTML> <HEAD> <TITLE></TITLE> </HEAD> <BODY> </BODY> </HTML>

Answer 3.
There are several of these special filename. The one that you have been introduced to in this lesson is Index.html
Although index.htm is often used some host servers prefer index.html
At this stage of the course you do not need to know about the other special file names.

More experienced students can find the file names listed at appendix.htm

Answer 4.
<P>
</P>

Answer 5.
<BR>

Answer 6.
<HR>
NO end tag,

Continue with Test

corner
Previous Top of Page Next page
Design

 

corner
space

 



In Association with Amazon.co.uk
In Association with Amazon.co.uk

In Association with Amazon.co.uk

 

 

 

Leisure Time - book your holiday or flights with our UK sponsors


Last minute

Save 10%
Book a Thomas Cook holiday Book a Thomson holiday Book a Portland Holidays Direct
Thomas Cook flights Thomson holiday flights Flybe Cheap flights British Airways flights My Travel flights
The London Pass - Adult The London Pass - Adult

Welcome to The London Pass, the brand new leisure pass that lets you experience the very best that London has to offer. With free entry to over 50 attractions, free public transport and the ability to beat the queues, The London pass helps you to make the most of your stay.


More Tutorials by John McGuinn

M206
Home page of a tutorial in programming in Smalltalk, a object-oriented programming language. This is an ideal tutorial for anybody learning Smalltalk and of particular interest to students on courses: M206 at the OU Open University, and course CSC517 at NCSU North Carolina State University

C programming tutorial
Home page of a tutorial in programming in C This is an ideal tutorial for anybody learning C programming language, and of particular interest to students on courses: T223 at the OU Open University.

tutorials4u.com
Home page of tutorials4u.com

Leeds my home town

Relax in the sun.

Benidorm   Tenerife   San Marino apartments to rent

 

Top

AireWeb Web Design
Leeds Web design

Copyright © John McGuinn 2001-03

.