
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML 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 Articles
- HTML href Attribute
- HTML href Attribute
- HTML href Attribute
- How to use href attribute in HTML Page?
- HTML DOM Anchor href Property
- HTML DOM Base href Property
- HTML DOM Link href Property
- HTML DOM Location href Property
- How to change the href attribute for a hyperlink using jQuery?
- How to get an attribute value from a href link in selenium?
- How to write a jQuery selector to find links with # in href attribute?
- How to find the href attribute of a link in a document in JavaScript?
- How to search the value of the href attribute of a link in JavaScript?
- Selects every element whose href attribute value ends with ".htm" with CSS
- HTML pattern Attribute

Advertisements