News:

This week IPhone 15 Pro winner is karn
You can be too a winner! Become the top poster of the week and win valuable prizes.  More details are You are not allowed to view links. Register or Login 

Main Menu

HTML basics - Headings

Started by ben2ong2, October 03, 2006, 05:44:41 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ben2ong2

Headings help in defining the format and structure of the document. They provide valuable tool in highlighting important topics and the nature of the document as a whole.

There are six levels of headings in HTML specified by <H1>, <H2>, <H3>, <H4>, <H5> and <H6> tags. The outputs of these in a browser are as follows:

<H1>I am heading 1</H1> gives:
I am heading 1
<H2>I am heading 2</H2> gives:
I am heading 2
<H3>I am heading 3</H3> gives:
I am heading 3
<H4>I am heading 4</H4> gives:
I am heading 4
<H5>I am heading 5</H5> gives:
I am heading 5
<H6>I am heading 6</H6> gives:
I am heading 6
As you can see, the heading tags come in pairs with the opening and closing tags. Any text surrounded by these tags will be displayed differently depending on the heading number.

Let us make another HTML file. Open Notepad and type in the following text. Save this document as 'headings.html'. View it in your browser.

<HTML>
<HEAD>
<TITLE>My fist HTML page with headings</TITLE>
</HEAD>
<BODY>
<H1>I am heading 1</H1>
<H2>I am heading 2</H2>
<H3>I am heading 3</H3>
<H4>I am heading 4</H4>
<H5>I am heading 5</H5>
<H6>I am heading 6</H6>
</BODY>
</HTML>



Attributes
Attributes change the properties of tags and are placed ONLY inside the starting tag. Each attribute usually has a value associated. The attribute-value pair is written as:

<TAG ATTRIBUTE="VALUE">some text ... </TAG>
Thus,
The attribute-value pair is placed INSIDE the starting tag
An "equal to" sign separates the attribute from its value.
The value part is surrounded by quotes. The quotes are necessary if the value contains spaces. However, I always use them and advice you to do so too.
Note: Some attributes do not require a value part.

All heading tags <H1> to <H6> have attributes. The important one are 'ALIGN' and 'TITLE'.

The ALIGN attribute
The 'ALIGN' attribute takes one of the four values: LEFT, RIGHT, CENTER, or JUSTIFY.

<H3 ALIGN="LEFT">I am aligned to the left</H3> yields:
I am aligned to the left
<H3 ALIGN="RIGHT">I am aligned to the right</H3> yields:
I am aligned to the right
<H3 ALIGN="CENTER">I am centrally aligned</H3> yields:
I am centrally aligned



The TITLE attribute
With the 'TITLE' attribute you can include some advisory text that is displayed when a user places the mouse pointer over the heading. Note, Netscape Communicator version 4.xx ignores the TITLE attribute of the headning tags.

<H3 TITLE="Here is my important heading">Some Important Heading</H3> is displayed as:
Some Important Heading
(If working in Internet Explorer, place your mouse cursor over the heading above to see how the TITLE attribute works.)


Default values to attributes
The keen-eyed would have noticed that the heading is aligned to the left even without explicitly specifying ALIGN="LEFT" inside a heading tag. This is because ALIGN="LEFT" is a default attribute-value pair for the heading tag.



An important point
Headings provide a logical flow to the document and should be used for that very purpose. They should never be used for changing font sizes. Font sizes can be easily changed by using the SIZE attribute of <FONT> tag or using style sheets.



You are not allowed to view links. Register or Login
You are not allowed to view links. Register or Login