Broad Network


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

Introduction

This is part 6 of my series, Text Elements in HTML. In this part of the series I talk about the attributes of the a element. In the previous series titled, “Basics of HTML 5”, I talked about the use of the a element; in this tutorial I will talk about the attributes of the a element. The a element is a text-level semantic element. It is an inline element and would fit itself in a line of text. The use of the a element is to create a hyperlink, which you should already know. The a element is a double tag element.

href
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>

download
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.

rel
I will talk about this attribute later, in a different series when talking about links in general.

hreflang
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.

type
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.

target
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.

_blank
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).

_self
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.

_parent
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.

_top
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.

Chrys

Related Links

Basics of HTML 5
Basics of ECMAScript
HTML DOM Basics
CSS Basics
Text Elements in HTML
Grouping Content
Microsyntax Dates and Times in HTML
Sectioning Content
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

BACK

Comments

Become the Writer's Fan
Send the Writer a Message