HTML Anchor Element
Text Elements in HTML – Part 6
Foreword: In this part of the series I talk about the attributes of the a element.
By: Chrysanthus Date Published: 24 Jun 2015
The value of this attribute is the URL (address) of the destination web page or resource, coded as in:
<a href="http://www.somesite.com/resource.ext">Name of Resource</a>
This attribute may or may not have a value. It can be present without a value as in,
<a href="http://www.somesite.com/page.htm" download>Name of Resource</a>
If present without a value, it means, when the user clicks the hyperlink, the resource will be downloaded and not opened (displayed) by the browser. For example, assume the resource is a normal web page to be opened by the browser. If the attribute is present, the browser will no longer open the web page, and the web page will be downloaded to be saved in the user’s hard disk. If the attribute is absent, the web page will be opened by the browser (automatically).
Now, if the attribute is present and it has a value as in,
download="New Name of file"
the value is the new name that the resource will be saved as.
If the attribute is absent (value is absent too), then the hyperlink will download the resource only if the browser cannot open the resource.
I will talk about this attribute later, in a different series when talking about links in general.
This attribute has a value. Its value is the language (English, French, German, etc.) of the destination resource. This attribute is only for advisory purpose to the browser. I will give you the details in a different series.
This attribute has a value. Its value is the type of the destination resource. This attribute is only for advisory purpose to the browser. I will give you the details in a different series.
This attribute can have any of the following values: _blank, _self, _parent, _top. I go on to give you an indication of what each of these values mean.
When the value of target is _blank as in,
<a href="http://www.somesite.com/page.htm" target=_blank>Name of Resource</a>
the document whose URL is the href value, is opened in a new tab (window).
When the value of target is _self, the document is opened in front of the one that has the hyperlink (a element), in the same tab. You will have to click the Back Button to go to the document that has the hyperlink.
When the value of target is _parent, the opening can be the same as for _self. I will explain the difference in a different series.
When the value of target is _top, the opening can be the same as for _self. I will explain the differences in a different series.
Note: The target, download, rel, hreflang, and type attributes must be omitted if the href attribute is not present.
That is it for this part of the series.
Related LinksBasics of HTML 5
Basics of ECMAScript
HTML DOM Basics
Text Elements in HTML
Microsyntax Dates and Times in HTML
Common Idioms without Dedicated Elements
HTML Embedded Content
HTML Insecurities and Prevention
Presentation Mathematical Markup Language
More Related Links
PurePerl MySQL API
Major in Website Design
Perl Course - Optimized
Web Development Course