HTML a href for Hypertext Links

❰a href❱ creates a hypertext link. ❰a❱ description, syntax, usage, attributes and examples. is a great guide for web Series & Actors and Actresses. FollowTV SeriesandHTML 5on Google+.

ATTENTION: THIS PAGE ISValid HTML 5AND IS BEST VIEWED WITHHTML 5- Please upgrade your browser or download one of the HTML 5 compatible browsers such as Mozilla Firefox, Chrome, Opera or IE 9 (March 14, 2011 or later). For more information seeHTML 5 browsers.

HTML a href for Hypertext Links

Deprecated Elements

Design Pattern Catalog

JavaScript Patterns

JavaScript objects

JavaScript functions

JavaScript Tutorials

If you find this helpful, please click theGoogle

Buttonto the left, if it is white, to make it turn blue or red. Thank you! (It also helps find this page again more easily.)

The a href tag is used to define a hypertext link. It is one of thetags for interactive content in HTML. If a user clicks on the link, the referenced document will be loaded by the browser or other web client. Only the a href version of the anchor tag is described here since thea nameversion is no longer used (seeChanges in HTML 5below)

A series ofinlinehypertext links can be used to create abreadcrumb trail:

This is an actual working demo of thea href example codebelow.

Thehrefattribute of the a tag can reference theidattribute of one of the HTML tags to link to a specific point within a web page, automatically scrolling the browser window if necessary to make that section of the web page appear in the currently visible area. To specify the target location, include a hash symbol () followed by theidof the target location in thehrefattribute of theatag. The URLs of bookmarks or favorites can also point to specific locations in a web page.

The tags that are involved in creating the document outline, which include thesection taghgroup tagandheading tagwould be some examples of good places for HTML anchors:

section id=main-section-a h1Section A/h1 … hgroup id=implied-section-b h2Section B/h2 h3…/h3 /hgroup … h2 id=implied-section-cSection C/h2 … /section

a name/anda id/anchor tags

The a/ tag was originally used to define a fixed point (hence the nameanchorand element type namea) in a document for the target of a hypertext link. However, starting withHTML version 4(1997), any HTML element can be used as an anchor simply by including anidattributeon the element start tag or thestandalone tagof avoid element. From:

Note that as a result of how the HTML specifications have evolved, the a tag shouldnotbe used as an anchor, and in order to avoid confusion, probably should not be called theanchor tag.

In addition to the a tag for hypertext links, theHTML link tagcan be used to reference other things, such as profiles of the web page author(s), related to the current HTML web page.

Make sure you understand thedifference between a tag and elementand are familiar with thedefinitionsofnamespaceand otherHTML terms.

element for a hypertext link where eitherflow contentis expected orphrasing contentis expected.

element with a starting a tag. The element name uses lower case letters and should be in theHTML namespace, which it will pick up automatically from the

within the same page, a URL of another web page or a URI such as a

Include any otherattributesof the a tag as appropriate.

element, code the text or otherphrasing contentthat is to appear as the hypertext link. If the

tag is coded whereflow contentis permitted, then theinner HTMLof the

Contents of the a href/ Tag

When coded inflow content, the content of theaelement can includeHTML commentstext contentand anyHTML tags that can be used in flow content.

When coded inphrasing content, the content of theaelement can includeHTML commentstext contentand only thoseHTML tags that can be used in phrasing content.

The a tag can be combined with many otherphrasing content tags, such as:

when the text in the link is an acronym or abbreviation

for a link to a web site whose content is being cited, or to a web site related to a creative work being cited

when the text in the link represents computer code, such as when the pages on this site link to the description and syntax of tags in the tag reference

when the link is an image rather than text

when the text in the link represents keyboard input

when the text in the link represents the search term(s) in search results

when the text in the link represents computer output

when the text in the link represents a time, which may be used to link to the full description of an entry in the chronological summary of some type of log or a blog

when the text in the link represents a variable that is to be replaced with an actual value

When their content is to be applied to the entire link, the a tag can be nested inside those tags, if theircontent model allows phrasing content, or those tags can be nested inside the a tag. Fortags with no allowable content, such as theimg tag, those tagsmustbe codedinsidethe a tag. Our recommendation is to always code them inside the a tag, since that makes it easier to make changes to the HTML code later. For example:

pAccording to a href= HTML/cite/a, the cite tag should be used for the title of a creative work, not the cited content. /p

To make it clear that the citation comes from abook, you would simply need to add the word book between the cite tag and the ending /a tag.

pAccording to the a href= HTML/cite book/a, the cite tag should be used for the title of a creative work, not the cited content. /p

URLof target page, a hash symbol and fragment identifier for another location within the current page or any otherURI reference(or IRI reference depending on theencoding) such as amailto:link

Usepercent escape codesas explained in theURL Encoding Tutorialfor any special characters in theURI reference.

If the value of thehrefattribute resolves to an, it may contain any of the following components:

If the protocol scheme, username, host name/IP address and port number are omitted the default is the current host – the same server as the base of the current document. If the path starts with a slash/…, it is an absolute path from the document root directory (AKAweb root) on the server. A relative path will be resolved relative to the base of the current document. A URI with a but no fragment identifier points to the top of the document.

ISO 639 country code with optional ISO 3166 country code

whether the target URL is designed for desktop web browsers, printer-friendly or designed for mobile devices

If a user clicks on this link, the URLs in the

attribute will be sent asynchronous notifications of the event. The list of URLs to be notified are separated by spaces. Each of the URLs will be notified via a HTTP POST request. The address of the current document will be sent in a

header, and, if the target is from the same domain, in a

[sic] header also. The target URL of the hypertext link from the

Therelattribute specifies the purpose of the link. It may contain a single keyword, or a list of rel attribute keyword values separated by spaces.

attribute values for hypertext links

The person described by the document containing the link considers the person described by the referenced document to be an acquaintance.

The referenced document is an alternate representation of the document containing the link. This should only be used when the referenced document has content similar to the current document but published in an alternate form, such as a syndicated feed for a list of blog posts (seerel=feed alternate). If the document has been translated into other languages, the language of the translation should be indicated in an

The referenced document is a list of previously created versions of related documents, such as the archives of a blog.

The link references a resource about the author of the document. For search engine optimization, Google recommends using a link to the authors Google Profile or a page about the author on the same domain as the link. It could also be a link to another type of resource, such as a

link to the email address of the author. See therel=author Tutorial.

Provides a permanent link to the document or to a section within the document.

The person described by the referenced document is a child of the person described by the document containing the link.

The person described by the referenced document lives in the same place as the person described by the document containing the link.

The person described by the referenced document works for the same company or organization as the person described by the document containing the link.

The person described by the referenced document works in the same field of employment as the person described by the document containing the link.

The person described by the referenced document is someone who might be contacted by the person described by the document containing the link.

The person described by the document containing the link has a crush on the person described by the referenced document.

The person described by the document containing the link has been dating the person described by the referenced document.

Indicates that the link is to a external resource on a different web site.

For feed autodiscovery, links to a syndicated feed channel for the document or the web site. Do not use or include

unless the current document and the feed are alternate forms of the same content; if the current entry is a subset of the feed, such as a single blog post, use

Used when the referenced document is the syndicated feed for the current content, such as the feed for a list of blog posts in an HTML page (but not a single blog post, which would be an entry or item in the feed rather than the entire feed).

Links to the first document in a series of articles.

The person described by the document containing the link considers the person described by the referenced document to be a friend.

Links to a document that provides helpful information related to the content of the document containing the link (not a general help page).

Links to a table of contents or index document that includes the document containing the link as well as others in the same collection of documents.

The person described by the document containing the link and the one described by the referenced document are members of the same extended family.

Links to the last document in a series of articles.

Links to a document that describes the copyright license that applies to the document(s) in which the link to the license page appears.

The person described by the referenced document is the same person as the one described by the document containing the link. They are two pages describing the same person.

The person described by the document containing the link claims to have met the person described by the referenced document.

The person described by the referenced document provides inspiration to the person described by the document containing the link.

The person described by the referenced document lives near the person represented by the document containing the link.

In a series of documents, the referenced document is the next one in sequence following the document containing the link.

The person described by the referenced document is a parent of the person described by the document containing the link.

Used in a link that provides the URL of the resource to handle a pingback for the document containing the link.

In a series of documents, the referenced document is the previous one in sequence prior to the document containing the link.

Links to a document that provides information that can be used by search engines. This could be an XML file conforming to theOpenSearch Description Documentspecification.

For a pair or siblings; the person described by the referenced document is a brother or sister of the person described by the document containing the link.

Indicates that the referenced document should be loaded into the web browsers sidebar if the link is activated by the user.

The person described by the referenced document is the husband or wife of the person represented by the document containing the link.

The person described by the document containing the link considers the person described by the referenced document to be their sweetheart.

Specifies aURIthat is a tag, which describes the subject of a page. The tag may be aURL, which leads to a web-accessible page, or just a standalone identifier.

Links to the document at the next higher level in a tree hierarchy. The value

points to the grandparent, and so forth. This can be used to create abreadcrumb trail, for example.

attribute values for links to external resources

Indicates that the referenced document should be automatically preloaded into cache.

Indicates to search engine crawlers and other robots that they should not follow the link to the referenced resource and process the document there. This can be used to indicate that the linked document should not be considered to be a recommended resource when determining the search engine rank for the linked page. This may help the page where the link appears from being penalized for recommending less desirable pages, such as for links to an affiliate site.

Indicates that the user agent should not identify the referring page to the server handling the request for the target page. If this value is omitted or ignored, theURLof the page containing the link will most likely be included in the

[sic] header of theHTTPrequest for the referenced page.

the window where the target url specified by the href attribute is to be displayed

RFC 2046 MIME media type and subtype

a href=back to top/a a href=target-within-pagelink within document/a a href=another-page.htmlanother page/a a href=/another-section/another section/a a href= Only/a a href= of using the a tag/a

The example link withhref=target-within-pageshows how to direct a link to another place in the same document. The target of the link is specified by coding anid attributeon any HTML element at the target location (notana name/ora id/element, which have been deprecated):

To keep the link text from breaking to wrap onto a separate line, include thewhite-space: nowrapstyle:

To open the page that a link references in a new window or tab rather than replacing the current page, add thetarget attribute. This can be used to allow a user to view pages from another site without leaving the current site.

To suppress the underline that indicates a hypertext link created by an HTMLaelement, add astyle=text-decoration: noneattribute to the starting a tag.

(seea href breadcrumb trail demoabove)

nav a rel=up up href=../../HTML 5/a a rel=up href=../HTML Tags/a bHTML a tag/b /nav

p id=examplesThis paragraph is the target of a hypertext link./p

Thefragment identifierisexamples. The browser should automatically scroll to that location on the page if a hypertext link includes a hash symbol () with the fragment identifier:

a href= of using the a tag/a

Examples of the a tag with other protocol schemes

a href=tel:+Call our feedback line at +1-/a

Example of link with an image using the HTML img tag

p style=text-align: centerClick this image to view the video tag demobr/ a href=../video-tag/examples img src=/media/deep-impact-movie.png width=160 height=120 alt=picture from deep impact movie / /a /p

This example uses the img tag to put an image inside an a tag that links to theHTML 5 video demo. Also shows how to resize an image; in this case the size of the image is changed from 320×240 to 160×120.

Click this image to view the video tag demo

Some search engines, particularly Google, may include a breadcrumb trail in their search engine results if the links includemicrodata properties for a breadcrumb trail.

Description, syntax, usage, attributes and examples of the HTML a href tag.

To code thebreadcrumb trail microdatathe breadcrumb trail list of links must include somemicrodata properties:

identifying each link in the breadcrumb trail

indicating the target URL of each breadcrumb link

that provides the text for each breadcrumb link

ul class=breadcrumb-trail li itemscope=itemscope itemtype= a itemprop=url rel=up up up href=/ span itemprop=titleHTML 5/span /a /li li itemscope=itemscope itemtype= a class=nobr itemprop=url rel=up up href=/tags/ span itemprop=titleHTML Tags/span /a /li li itemscope=itemscope itemtype= a itemprop=url rel=up href=./ span itemprop=titleHTML a href Tag/span /a /li li itemscope=itemscope itemtype= a itemprop=url href=examples span itemprop=titleExamples/span /a /li /ul

bodypBy address

a href=mailto:John.John Doe (contact the author)/a

/address/p … /bodyarticleh2April Fools!h2 pPublished: Friday, April 1, 2011br/ By:address

a href=mailto:John Doe John.John Doe (contact the author)/a

/address /p pTodays blog entry is an April Fools Day joke…./p /article

The a href tag is coded inside anaddresselementindicating that the address is for the author of the content. The value of thea hrefattribute starts with themailtoscheme followed by a semicolon (:). The To address follows it and can be coded as:

, which may include special characters if enclosed in quotes (

in an attribute value, and the e-mail address enclosed in angle brackets (

), which must be encoded with theHTML character entities

Themediaattribute has been added for consistency with thelink tag.

Thetargetattribute has been resurrected in HTML 5. It really did not exist in either HTML 4 or XHTML, although it was the easiest way to open a web page in a new window. As a result, it was used on many web pages, which therefore would fail validation.

In HTML 5, you can put the a tag around block elements in addition to inline elements. This means that links can appear where they couldnt before. For example, you can turn a wholeHTML table rowinto a link:

table trtdLabel:/tdtdData…/td/tr … tr onclick=location=this.getElementsByTagName(a)[0] a href=new-row.html/ td colspan=2Add a Row/td /tr /table

Differences between HTML 5 and earlier versions of HTML

Theatag with anameoridattribute is no longer used as a placemark for the target of a hypertext link. Most HTML tags may now include anidattribute for that purpose. Therefore, whenever there is an a tag with anidornameattribute but nohrefattribute, the value of the attribute should be coded as theidattribute of the tag following it:

pNew features of HTML 5 include …./p

p id=whats-new

New features of HTML 5 include …./p pSee a href=whats-new

Whats New in HTML 5/a above./p

Anatag without anhrefattribute is now only a placeholder that may later be turned into a hypertext link via dynamic JavaScript code.

The following attributes shouldnotbe coded on the a tag because they either have been deprecated or were never officially supported:

– if the tag is being used for both a hypertext link and the target of a reference from somewhere else, use the

attributeinstead; if its not a hypertext link, code the

attribute on a different tag at the target location as shown above

The2000-2010 Recommendations from the W3C HTML Working Groupdefined theHTML namespacefor theaelement type name along with the names of allHTML element types. In older (pre-2000)versions of HTML, element type names were not associated with a namespace.

Watch TV shows onlineatTV Series . Includesfree TV show episodes. Now optimized for watching shows on Google TV and on tablets such as the Kindle Fire.