HTML Basics

What is HTML?

HTML stands for Hyper Text Markup Language. Web designers use HTML to mark up content with codes called tags that tell web browsers how to display this content.

 

Tags

The following are examples of HTML tags: <b>, <font>, <img>
Tags affect the presentation of the content following them. For example, <b> is the bold tag. Anything following the <b> tag will be displayed in bold by the web browser.

<b> I am affected by the bold tag</b> will be displayed as as I am affected by the bold tag

Notice the </b> tag. This is called a closing tag. Closing tags indicate the point where you want the effect of the opening tag to stop. In the above example, the </b> tag says "stop bolding text here". It is good style to have a closing tag for each opening tag in an HMTL document.

 

Hello World.

Traditionally, the first program or script written in any language is Hello world!. It is rumoured that horrible things will happen to those who break this tradition. We shall not be the first to do so.

<html>
<head>
<title>Hello World!</title>
</head>
<body>
Hello world!
</body>
</html>

The <html> and </html> tags tell the browsers to expect HTML code in this file.
The <head> and </head> tags tell the browser to look for header information here. The page title is an example of this header information.
The <title> and </title> tags tell the browsers what to display in the title bar at the top of the screen. The title for this page is "NASA Sharp HTML Tutorial"
The <body> and </body> tags contain the bulk of the content of the web page.

 

Saving and viewing your web pages

Copy the Hello World example to your favourite text editor - notepad or wordpad are fine. Save the file making sure to give it an .html or .htm extension. E.g. hello.html. Now you can open the web page with Mozilla, Internet Explorer, or any other web browser. After - and only after - trying the Hello World example, feel free to play around with the content of the tags.

 

Formatting text.

Your web pages will probably contain a lot of text. It is therefore important for you to know how to format this text. In this section we take a look at some of the tags commonly used for formatting.

Headings

The <h?> tags a.k.a the heading tags are used to create bold text that are good for section headings and subheadings.

<h1>This is the highest level</h1>
<h3>This is an intermediate level</h3>
<h6>This is the smallest heading level</h6>

Bold

The <b> </b> tags are used to create bold text.

Italics

The <i> </i> tags are used to create italicized text.

Underline

The <u> </u> tags are used to create underlined text.

Paragraph

The <p> tag creates a new paragraph. The <p> is one of the few tags that do not need closing tags. Its effects last until the next tag is encountered. The <p> tag also takes extra options. For example <p align = "right"> tells the browser to display a paragraph that is right justified (lined up against the right page border). The three alignment options for the <p> tag are "left", "right", and "centre"

Font

The <font> tag is used to specify the size, colour and font of text. <font> also takes extra options. For example, <font color="green" face="Arial" size="7"> says "format this text using green 7 point sized arial font"

Center

Any content between the <center> and <center> tags
will be centered on the page

Images

Images are inserted using the <img> tag. For example, <img src="http://www.cs.wisc.edu/images/logo-crest.gif"> will display
<img> does not require a closing tag.

 

Click here for more html tutorial magic