<A> tag creates hyperlink that links to another html file using the href attribute <A HREF = target_url.... >.
Or creates hyperlink to target another anchor in the same html file by pointing <A HREF = target_anchor_name .... > to the target anchor <A NAME = #anchor_name... >.

1. Create Hypertext that links to another html file with Anchor tag <A HREF...>


  figure above shows a hypertext link that links to another html file using href attribute.
<HTML>
  <BODY>
    <A TARGET="_blank" HREF="http://www.geek-tutorials.com">
      Link to Geek-Tutorials.com
    </A>
  </BODY>
</HTML>

2. Create Hypertext link to target another Anchor tag <A NAME....>
All about Food 1
All about Food 2
All about Food 1
Fish is a fantastic dish be it
smoked, steamed,grilled,baked,
poached, or pan fried.
Fish is a fantastic dish be it
smoked, steamed,grilled,baked,
poached, or pan fried.
All about Food 2
Thick and Creamy Soups,
breads and cheese are
great for breakfast.
  figure above shows hypertext link to target another anchor in the same html file with name attribute.
<HTML>
  <BODY>
    <!-- Link to an anchor with href attribute -->
    <A HREF="#Food1">All about Food 1</A><BR/>
    <A HREF="#Food2">All about Food 2</A><BR/>

    <!-- Define an anchor with name attribute -->
    <A NAME="Food1"><B>All about Food 1</B></A><BR/>
    Fish is a fantastic dish be it<BR/>
    smoked, steamed,grilled,baked,<BR/>
    poached, or pan fried.<BR/>
    Fish is a fantastic dish be it<BR/>
    smoked, steamed,grilled,baked,<BR/>
    poached, or pan fried.<BR/>
    <A NAME="Food2"><B>All about Food 2</B></A><BR/>
    Thick and Creamy Soups,<BR/> 
    breads and cheese are<BR/> 
    great for breakfast.
  </BODY>
</HTML>

<A> Optional Attributes :
charset <A CHARSET = character_encoding....>

Specifies the character encoding of the target URL or destination page.

coords

<A SHAPE="rect" COORDS = "left-x, top-y, right-x, bottom-y".....>

<A SHAPE="circle" COORDS = "center-x, center-y, radius".....>

<A SHAPE="poly" COORDS = "x1, y1, x2, y2, ..., xN, yN.".....>

Specifies the coordinates of an image map appropriate to the shape of the region being defined.

If the shape is :
rect: left-x, top-y, right-x, bottom-y.
circle: center-x, center-y, radius.
poly: x1, y1, x2, y2, ..., xN, yN. The first x and y coordinate pair and the last should be the same to close the polygon.

href <A HREF = target_url_or_anchor.... >

specifies the hypertext link to target URL or to specify the hypertext link to target anchor.
Eg. target url : <a href="http://www.geek-tutorials.com">
Eg. target anchor : <a href="#Food1">

hreflang <A HREFLANG = language_code..... >

specifies language code of the target URL.
Eg. language_code : <A HREFLANG = "ja".....> for japanese version language.

name <A NAME = #anchor_name... > specifies the name of the target anchor.
rel alternate
appendix
bookmark
chapter
contents
copyright
designates
glossary
help
index
next
prev
section
start
stylesheet
subsection
Specifies the relationship between the current document and the target URL.
rev alternate
appendix
bookmark
chapter
copyright
glossary
help
home
index
next
prev
section
start
stylesheet
subsection
Specifies the relationship between the target URL and the current document.
shape <A SHAPE = "rect".... > or
<A SHAPE = "circle".... > or
<A SHAPE = "poly".... >
specifies the shape of the region for the image map.
target <A TARGET = "_blank".... > or
<A TARGET = "_parent".... > or
<A TARGET = "_self".... > or
<A TARGET = "_top".... >
specifies type of frame to load the target URL's page.
_blank - renders the link in a new, unnamed window
_parent - renders the link in the parent frame
_self - renders the link in the current frame
_target - renders the link in the full, unframed window
type value : MIME content part specifies the MIME (Multipurpose Internet Mail Extensions) type of a linked resources.

Other Attributes :
Core Attributes class, id, style, title.
Internationalization Attributes lang, dir.
Event Attributes onblur, onfocus, onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup
Keyboard Attributes tabindex, accesskey

  Below describe the attributes for <A> tag in detail.


Core Attributes

Attribute Syntax Description
CLASS

eg. an element's class :
<ELEMENT CLASS = stClass...>

eg. multiple classes in an element :
<ELEMENT CLASS = stClass [ stClass2 [ stClass3 ... ] ] ... >

 

An element can belong to multiple classes.
Multiple elements can share the same class.

Common Usage : to associate a particular style rule in a style sheet with the element.

stClass = a string of class attribute value

Attribute value for CLASS is space-separated list of class names. Begin with a letter range from A-Z or a-z and may be followed by letters (A-Za-z), digits (0-9), hyphens ("-"), underscores ("_"), colons (":"), and periods ("."). The value is case-sensitive.

ID <ELEMENT ID = stID... >

A unique id for an element.

Common Usage : as a target for links or for naming particular elements in a style sheet.

stID = a string which specifies attribute value for ID

Attribute value for ID begin with a letter range from A-Z or a-z and may be followed by letters (A-Za-z), digits (0-9), hyphens ("-"), underscores ("_"), colons (":"), and periods ("."). The value is case-sensitive.

STYLE <ELEMENT STYLE = stStyle ... >

Specify an inline style for the element.

Common Usage : to associate a particular style sheet rule for the element.

stStyle = a string to specifies the inline style type.

Attribute value for STYLE is the type of the style sheet language or style rules.
Eg. <ELEMENT STYLE="font-family: Verdana">text...</ELEMENT>.

TITLE <ELEMENT TITLE = stTitle... >

Specify the title for the element.

Common Usage : as a tooltip to retrieve advisory information when user hover the mouse over the object.

stTitle = a string that specifies the title attribute value.

Attribute value for TITLE is space/non space-separated list of text.

Internationalization Attributes

Attribute Syntax Description
DIR <ELEMENT DIR = stDir... >

Sets the text direction

stDir = attribute value for DIR

Attribute value for DIR is the directionality of text from left-to-right (DIR=ltr, the default) or right-to-left (DIR=rtl).

LANG <ELEMENT LANG = stLang... >

Sets the language code

stLang = attribute value for LANG

Attribute value for LANG is non space-separated, case-insensitive with the following values : (LANG=en) for English, (LANG=ja) for Japanese and etc.

Event Attributes

Attribute Description
onBlur when an element loses focus.
onFocus when an element gets focus.
onClick the mouse button is clicked on an element.
onDblClick the mouse button is double-clicked on an element.
onMousedown the mouse button is pressed over an element.
onMouseup the mouse button is released over an element.
onMouseover the mouse is moved onto an element.
onMousemove the mouse is moved while over an element.
onMouseout the mouse is moved away from an element.
onKeypress a key is pressed and released over an element.
onKeydown a key is pressed down over an element.
onKeyup a key is released over an element.

Keyboard Attributes

Attribute Syntax Description
TABINDEX <ELEMENT TABINDEX = number_value... >

Used to assign tab order of an element.

number_value = an integer value to specify the tab order of the element.

Attribute value for TABINDEX can be 1, 2, 3 and so on ... to specify the tab order for each element.

ACCESSKEY <ELEMENT ACCESSKEY = keyboard_keys_value... >

Used to assign a keyboard shortcut to access an element.

keyboard_keys_value = Character value on an alphanumeric keyboard.