indiWiz.com
SiteSearch:
Jump:

Site Map | WizTools.org | jCraze Blog
Web Developer's Den!
Home : WDD : HTML
This Article...
Print Version
Add Comment
View Comments
HTML
HTML Primer 1
HTML Primer 2
Hyperlinks
Color Guide 1
Color Guide 2
Fonts in HTML
HTML Lists
Table Tutor 1
Table Tutor 2
HTMLfx
HTML Special Characters
HTML Editors
Animation and HTML
XHTML - The Bare Facts
Sections

Commniquè
Sign Guestbook!
Read Guestbook!
MailMe!

Subhash's HTML Primer 2

< With XHTML & XML References >

After all the theory of HTML Primer 1, it is now time to go practical! Open your text editor, create a new document with the content given below, and save it as "first.html":

<html>
<head>
<title>My Page!</title>
</head>
<body>
<p>Hello World!</p>
</body>
</html>

(Note: All HTML documents need to be saved with the extension ".html" or ".htm".)

Now go the folder where you saved this file and click to open it. It should open in your web browser. In my Netscape6.x browser the page looked like this:

Netscape's Rendering of Page

Notice the message "My Page!" being displayed in the title bar. That is what the <title> tag does. The <p> tag, within the <body> is the paragraph tag. Now make some changes to this file. Change the paragraph thus:

<p>Hello
World!</p>

Save the file and refresh your browser (Usually View>Refresh). You will notice no change in the browser rendering of your page. That is because HTML treats every kind of space - line feeds, tabs, newlines, multiple spaces - as single space. If you do want to print "World!" in the next line, you have to make use of the <br> tag:

<p>Hello <br> World!</p>

The <br> tag creates a line break. So far our <p> has been present without much formatting. Some of the formatting tags:

  • <i>...</i>: Italic Text
  • <b>...</b>: Bold Text
  • <strong>...</strong>: Strong Text
  • <em>...</em>: Empahsized Text
  • <u>...</u>: Underlined Text
  • <strike>...</strike>: Strike-through Text
  • <sup>...</sup>: Superscript Text
  • <sub>...</sub>: Subscript Text

Suppose you want to display "Hello" in bold and "World!" in italics, the <p> tag would be modified as:

<p><b>Hello</b> <i>World!</i></p>

You can check out other formatting tags in similar fashion. Shouldn't we now move on to Paragraph formatting options? Suppose you want to center the above paragraph, you would modify the code to:

<p align="center"><b>Hello</b> <i>World!</i></p>

The align attribute also takes the following valid values:

  • left
  • right
  • justify

Enough of <p>! Our document has been without a heading for quite some time. Shouldn't we add one? Heading tags are defined from <h1> to <h6>. <h1> creates the biggest looking heading and <h6> the smallest. Most of <p>'s attributes and sub-tags (<b>, <i>, etc.) work with <h#> tags too. For our example, we will create a <h3> with centered alignment:

<h3 align="center">My First HTML</h3>

This should look as:

My First HTML

One last tag which I must cover in this primer is the <pre> tag. In some cases you may want to retain the text formatting, as you have typed, of part of your text. You put that part of the text within this tag. The text is displayed as it has been formatted.

Using "HTMLTry!"

So far in this tutorial we have been asking you to try out your HTML tags in your local disk. Once you master that(?), for checking how your page displays when you use a particular tag, you can use HTMLTry!. Just click on the HTMLTry! button on the top of this document.


User Comments

Add Comment

[Quick Stats: Number of main threads: 0, Number of sub-threads: 0]

Sign Guestbook | Who is Subhash?
The contents of this site are copyright© 2000-2008, indiWiz.com. All Rights Reserved.