HTML CSS Bootstrap Javascript Icons Python
HTML References
HTML - Tag Reference HTML - Tag by Category HTML - Attributes HTML - Global Attributes HTML - Events HTML - Language Codes HTML - Country Codes HTML - URL Encoding HTTP Methods HTTP Status Codes <input> types
All HTML Tags
<!-- --> <!DOCTYPE> <a> <abbr> <acronym> <address> <applet> <area> <article> <aside> <audio> <b> <base> <basefont> <bdi> <bdo> <big> <blockquote> <body> <br> <button> <canvas> <caption> <center> <cite> <code> <col> <colgroup> <data> <datalist> <dd> <del> <details> <dfn> <dialog> <dir> <div> <dl> <dt> <em> <embed> <fieldset> <figcaption> <figure> <font> <footer> <form> <frame> <frameset> <h1> - <h6> <head> <header> <hr> <html> <i> <iframe> <img> <input> <ins> <kbd> <label> <legend> <li> <link> <main> <map> <mark> <meta> <meter> <nav> <noframes> <noscript> <object> <ol> <optgroup> <option> <output> <p> <param> <picture> <pre> <progress> <q> <rp> <rt> <ruby> <s> <samp> <script> <section> <select> <small> <source> <span> <strike> <strong> <style> <sub> <summary> <sup> <svg> <table> <tbody> <td> <template> <textarea> <tfoot> <th> <thead> <time> <title> <tr> <track> <tt> <u> <ul> <var> <video> <wbr>

HTML <a> tag

The HTML <a> element (or anchor element) creates a hyperlink to other web pages, files, locations within the same page, email addresses, or any other URL.

An anchor i.e. the <a> element can be used in two ways:

Run code

By default, links will appear as follows in most of the browsers:

However you can overwrite this using CSS. Learn more about styling links.

Browser compatibility

The <a> element is fully supported by all browsers:

<a> yes yes yes yes yes


The following table shows the attributes that are specific to the <a> tag:

Attribute Value Description
charset character_encoding
Not supported in HTML5.
Defines the character encoding of the linked document.
coords coordinates
Not supported in HTML5.
Defines the coordinates of a link
download filename This attribute instructs browsers to download a URL instead of navigating to it, so the user will be prompted to save it as a local file.
href URL Specifies the URL of a page or the name of the anchor that the link goes to.
hreflang language_code Specifies the language code of the destination URL.
media media_query Specifies what media/device the linked document is optimized for.
name section_name
Not supported in HTML5. Use the global id attribute instead.
Specifies the name of an anchor
Describes the relationship between the current document and the linked document
rev link_type
Not supported in HTML5.
Specifies the relationship between the linked document and the current document
Specifies where to open the URL

Global Attributes

The <a> tag supports the global attributes described in HTML Global Attributes Reference

Event Attributes

The <a> tag supports the event attributes described in HTML Events Reference

More Examples

Linking to another section on the same page:

Run code

Creating a clickable image:

Run code

Creating an email link:

Run code

Creating a phone link:

Run code

Open a link in a new browser window:

Run code

Using the download attribute to save a file:

Run code

Add JavaScript code inside the href attribute:

Run code

Last updated: Friday 24 Aug, 2018