This element defines a hyperlink, the named target destination for a hyperlink, or both.
href
attribute has the URL linking to
other web page or resource. label
is used
to display information for web page visitors.
<a href="http://www.example.com">label</a>
Anchor name starts with #
. It marks a linkable area inside a page. We can use
anchor link to hyperlink to a specific part in a web page.
<a href="#anchorName">label</a>
<a accesskey="key" charset="character code for language of linked resource" class="class name(s)" coords="comma-separated list of numbers" dir="ltr | rtl" href="URL" hreflang="language code" id="unique alphanumeric identifier" lang="language code" name="name of target location" rel="comma-separated list of relationship values" rev="comma-separated list of relationship values" shape="default | circle | poly | rect" style="style information" tabindex="number" target="frame or window name | _blank | _parent | _self | _top" title="advisory text" type="content type of linked data" > </a>
<a> |
Yes | Yes | Yes | Yes | Yes |
HTML5 has some new attributes, and some HTML 4.01 attributes are deprecated.
The <a> tag supports the Global Attributes in HTML.
The <a> tag supports the Event Attributes in HTML.
a:link, a:visited { color: (internal value); text-decoration: underline; cursor: auto; } a:link:active, a:visited:active { color: (internal value); }
A demo showing how to use anchor tag to create hyperlink and anchor.
<html>
<body>
<a name="top"></a>
<a href="http://www.java2s.com">java2s.com</a>
<a href="#par3">Go to paragraph #3 in this page</a>
<p><a href="yourdocument.html#sty">
Go to the yourdocument.htm page,sty location</a></p>
<p><a name="par3">Paragraph #3</a></p>
<p><a href="#top">Top</a></p>
</body><!-- w w w . j ava 2s. c o m-->
</html>