

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML <a> href Attribute
The <a> href attribute is used to set the link i.e. the URL of the page.
Syntax
Following is the syntax −
<a href="URL">
Above, URL is the url you need to mention, which can be a relative link, absolute link, script, protocol, etc.
Example
Let us now see an example to implement the href attribute of the <a> element −
<!DOCTYPE html> <html> <body> <h2>Learning is Fun</h2> <p> Learn the concepts of <a href="https://tutorialspoint.com/java">Java!</a> Also try JavaScript from our website: <a href="/javascript">JavaScript!</a> </a> </p><br> </body> </html>
Output
This will produce the following output −
Example
Let us see another example wherein we can set the email-id of a user with a href −
<!DOCTYPE html> <html> <body> <h2>Learning is Fun</h2> <p> Learn the concepts of <a href="https://tutorialspoint.com/java">Java!</a> Also try JavaScript from our website: <a href="/javascript">JavaScript!</a> <p>For more tutorials, kindly <a href="mailto:abcd@demo.com?cc=pqr@demo.com&subject=DEMO EMAIL">EMAIL</a></p> </a> </p><br> </body> </html>
Output
This will produce the following output −
If you will run the above on a system and click the EMAIL, then it will open the following application for email, which is set as default. Here, we have set the default email application as OUTLOOK −
- Related Questions & Answers
- HTML <link> href Attribute
- HTML <base> href Attribute
- HTML <area> href Attribute
- How to use href attribute in HTML Page?
- HTML DOM Anchor href Property
- HTML DOM Link href Property
- HTML DOM Location href Property
- HTML DOM Base href Property
- How to get an attribute value from a href link in selenium?
- How to find the href attribute of a link in a document in JavaScript?
- How to write a jQuery selector to find links with # in href attribute?
- HTML accept Attribute
- HTML accesskey Attribute
- HTML autofocus Attribute
- HTML checked Attribute
Advertisements