HTML <a> with href Attribute
HTML <a> with href Attribute
The href
attribute contains the URL of the page the link goes to.
Using href
attribute you can navigate to a page within your website and the other website.
Relative URL
When navigating to a page within your website it is not necessary to mention the protocol (http), and the hostname (www.example.com)
Relative URL of this page is /html/tag-a/attribute-href
Absolute URL of this page is http://wikimass.com/html/tag-a/attribute-href
Tips: It is recommended to use relative URL over absolute URL when navigating to a page within your website because it saves lots of file size.
Example
Absolute URL
When navigating to a page on the other website you have to use the absolute URL.
Example
href with JavaScript as Value
In the following example, href value is javascript:alert('Hello there!');, where javascript: in the front phase, tell the browser to execute the href value as javascript code.
Example
Move to a Section within a Page
In the following example, the href value is #css;, where # (hash) in the front phase, tells the browser to move to the section in the same page where id="css".
Example
Mail to One User
In the following example, href value is mailto:one@gmail.com?subject=Curiosity&body=How%20are%20you?, where mailto: in the front phase, tells the browser to execute the href value as mail content.
Example
Mail to Mulitple User
The following example is same as previous example, but here we are mailing to multiple user.
Note: Multiple users are comma-separated.
Example
Mail With CC and BCC
The following example is same as previous example (Mail to one user), but here we are mailing to one user with CC (Carbon Copy) and BCC (Blind Carbon Copy).
Example
Reminder
Hi Developers, we almost covered 99.5% of HTML Tutorials with examples for quick and easy learning.
We are working to cover every Single Concept in HTML.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.