a ... ⁄a
HTML5 a element
The a element allows you to create a hyperlink, a hypertext anchor, or represents simply a placeholder. »video
About a
- is an optional element
- multiple a elements allowed per HTML5 document
Display & support a
- display in browser »video





Parents, children a
- a nested within elements »a parents
- elements nested within a »a children
»examples
Attributes a
- required: none
- optional: specific attributes, global attributes, event attributes
Observations:
- if href attribute is not present → a placeholder; a element has no attribute
- if href attribute is present → a hyperlink or a hyper anchor
- if href attribute is present → all other specific attributes can be specified on a element
Warning
Within the a element (between the start tag and the end tag), interactive content is not allowed »details
Syntax a
1 | <> ... </> »video |
Attributes and Values a (comma separated)
< | attribute | = | "attribute_value(s)" | > | Video | Examples |
---|---|---|---|---|---|---|
1. specific attributes | ||||||
1. | download | = | resource name | »video | <href="getinfo/cours.pdf" download> ... <⁄ > | |
2. | href | = | URL | »video | <href="file.php"> ... <⁄ > | |
3. | hreflang | = | language code | »video | <href="file.php" hreflang="en"> ... <⁄ > | |
4. | ping | = | URL | - | <href="#demo" ping="test.php/demo"> ... <⁄ > | |
5. | rel | = | alternate, author, bookmark, help license, next, nofollow, noreferrer prefetch, prev, search, sidebar, tag | »video | <href="http://..." rel="nofollow"> ... <⁄ > | |
6. | target | = | _blank, _self, _parent, _top, a valid browsing-context name | »video | <href="file.php" target="_blank"> ... <⁄ > | |
7. | type | = | MIME type | »video | <href="file.php" type="text/html"> ... <⁄ > | |
All Specific Attributes | ||||||
2. global attributes | ||||||
1. | accesskey | = | keyboard key | »img | <accesskey="h"> ... </ > | |
2. | class | = | class name | »html »img | <class="class_name"> ... </ > | |
3. | contenteditable | = | "", , true, false | »html | <contenteditable="true"> ... </ > | |
4. | contextmenu | = | menu id value | »html | <contextmenu="menu_id_value"> ... </ > | |
5. | data-* | = | value | - | <data-http-error="404"> ... </ > | |
6. | dir | = | ltr, rtl, auto | »html | <dir="ltr"> ... </ > | |
7. | draggable | = | true, , false | »img | <draggable="false"> ... </ > | |
8. | dropzone | = | copy, move, link, string:, file: | - | <dropzone="copy"> ... </ > | |
9. | hidden | = | "", , hidden | »html »img | <hidden="hidden"> ... </ > | |
10. | id | = | id name | »html »img | <id="unique_id_name"> ... </ > | |
11. | itemid | = | URL | - | - | |
12. | itemprop | = | string | »link »a | <href="http://..." itemprop="url"> ... </ > | |
13. | itemref | = | string | - | - | |
14. | itemscope | = | "", , itemscope | - | - | |
15. | itemtype | = | absolute URL | - | - | |
16. | lang | = | language code | »html »head»title »img | <lang="en"> ... </ > | |
17. | spellcheck | = | "", , true, false | »html | <spellcheck="true"> ... </ > | |
18. | style | = | CSS property:value | »html »img | <style="color:red"> ... </ > | |
19. | tabindex | = | integer | »img | <tabindex="3"> ... </ > | |
20. | title | = | text | »html »link»style »abbr»dfn »img »meter | <title="html page"> ... </ > | |
21. | translate | = | "", yes, no | »html »img | <translate="yes"> ... </ > | |
All Global Attributes | ||||||
3. global event attributes | ||||||
1. | onclick | = | script | » list | <element onclick="script" > ... | |
2. | ondblclick | = | script | » list | <element ondblclick="script" > ... | |
All Event Attributes |
Video demonstration a element
HTML5 a tag: hyperlink, hypertext anchor, placeholder
min | video details |
---|---|
00:06 | video tutorial: a element objective: understanding the a element |
00:10 | a element allows you to: 1. create a hyperlink 2. create a hypertext anchor 3. when href attribute is absent, represents nothing but a placeholder |
00:21 | create a hyperlink using a element |
00:24 | linking the 'a hyperlink' text to w3-video.com: - adding the a start tag and end tag - adding href attribute on a start tag - adding a value (a valid URL) to the href attribute |
00:37 | saving the modifications in Notepad++ |
00:38 | refreshing the page in browser |
00:40 | the text 'a hyperlink' became blue |
00:41 | text: clicking the blue text |
00:43 | test result: OK , the linked resource, w3-video.com, displays |
00:50 | create a hypertext anchor using a element |
00:53 | - adding the a start tag and end tag - adding href attribute on a start tag - see 01:26 |
01:08 | adding some random text on page, for example purpose |
01:20 | adding an id to this last text, value="last" |
01:26 | - adding the value of the id - the value is: last - to a element, as value of the href attribute, preceded by # |
01:35 | the hypertext anchor is created |
01:36 | saving the modifications in Notepad++ |
01:37 | refreshing the html page in browser |
01:38 | the text: 'a hypertext anchor' became blue |
01:39 | test: clicking the blue text |
01:41 | test result: ok , we were taken to the element that has the id="last" |
01:47 | a represents just a placeholder |
01:47 | when href attribute is absent, a element represents nothing but a placeholder → it means that in the future we could add the href attribute on this a element and make the text contained by the a element: - a hyperlink, - a hypertext anchor or - a hyperlink with a hypertext anchor |
01:50 | adding just the start tag and the end tag of the a element |
01:54 | saving the modification in Notepad++ and refreshing the page in browser |
00:58 | note: the text: 'or represents just a placeholder' did not turn to blue; that text is not clickable, that text does not represent a hyperlink or an anchor, it's simply a placeholder |
02:05 | "a hyperlink": this text links to w3-video.com |
02:07 | "a hypertext anchor": this text links to an element from the same page, having the id="last" |
02:12 | "or represents just a placeholder": this text links to nothing |
02:15 | a element allows you to create a: - hyperlink - hypertext anchor - hyperlink with a hypertext anchor |