w3resource

HTML a tag and element

1. HTML a element defines a hyperlink in an HTML document.

2. a element starts with <a> tag and ends with </a> tag.

3. Value of the href attribute of an a element holds the target resource of the hyperlink.

4. Text written within the <a> and </a> tags is called anchor text.

Syntax

<a href="linked_resource">Text or Image </a>

Whether both start and end tags are required

Both start and end tags are required.

Can contain

HTML a element can contain inline elements except a.

Can reside within

HTML a element can reside within Block-level elements as well as inline elements except a and button.

Attributes

Attributes specific to this element

name, href, hreflang, type, rel, rev, charset.

Identifiers

id, class.

language information and text direction

lang, dir.

Title

Title.

Style

Style.

Events

onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup.

Image maps

shape and coords.

Target frame information

target.

Tabbing navigation

tabindex.

Access keys

accesskey.

Example of using HTML a element

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>html-a-tag-example</title>
</head>
<body>
<p>We are learning HTML at <a href="/index.php">w3resource.com</a></p>
</body>
</html>

Result

html a element

View this example in a separate browser window

HTML a tag example.

Pictorial presentation

html a tag example

Previous: HTML td tag and element
Next: HTML link tag and element

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.