
- 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
How do we include an anchor in HTML?
In this article we are going to perform the task of how do we include an anchor in HTML. Let’s dive into the article to know mpore about anchor in HTML.
The anchor element is used to link a source anchor to a destination anchor. The destination is the resource that the source anchor connects to, while the source is the text, picture, or button that points to another site.
The hyperlinks are one of the key technologies that make the internet the information superhighway.
To understand better on how do we include an anchor in HTML, let’s look into the following examples
Example 1
In the following example we are creating a jumping anchor link.
<!DOCTYPE html> <html> <head> <style> .main-content { height: 90vh; text-align: justify; } </style> </head> <body> <h2 id="tutorials">Tutorials Point</h2> <p class="main-content"> Tutorials Point originated from the idea that there exists a class of readers who respond better to online content and prefer to learn new skills at their own pace from the comforts of their drawing rooms.The journey commenced with a single tutorial on HTML in 2006 and elated by the response it generated, we worked our way to adding fresh tutorials to our repository which now proudly flaunts a wealth of tutorials and allied articles on topics ranging from programming languages to web designing to academics and much more.</p> <p>Click To <a href="#tutorials">Jump</a>. </p> </body> </html>
On running the above script, the output window pops up, displaying the text used in the above script along with an anchor tag mentioned "click to jump", which allows the user to jump to the start of the page when pressed.
Example 2
Considering the following we are creating a example of linking to the anchor from another web page.
<!DOCTYPE html> <html> <body> <h2 id="Tutorials">TutorialsPoint</h2> <p>Tutorials Point originated from the idea that there exists a class of readers who respond better to online content and preferto learn new skills at their own place from the comforts of their drawing rooms.</p> <p> <a href="https://www.tutorialspoint.com/market/index.asp">Go To The Course Page.</a> </p> <p> <a href="https://www.tutorialspoint.com/latest/ebooks">Search For Ebooks.</a> </p> </body> </html>
When the script gets executed, it will generate an output displaying the text used in the above script along with a link attached to the webpage using the anchor tag. When the user clicks on the link, it will open the new page.
Example 3: Using JavaScript
Looking into the following example we are creating a link to javascript.
<!DOCTYPE html> <html> <body> <a href="javascript:alert('Welcome To TutorialsPoint!');">Click To Execute</a> </body> </html>
When the given script is executed, it will provide an output that includes a link placed on the webpage using an anchor with the text "click to execute."
If the user clicks on the link, the script gets triggered and displays an alert "welcome to tutorials point".
- Related Articles
- How do we include an emphasized text in HTML?
- How do we include a section in an HTML document?
- How do we include an inline sub window in HTML?
- How do we include big text in HTML?
- How do we include a table caption in HTML?
- How do we include attributes for table columns in HTML?
- How do we include the legal number intervals for an input field in HTML?
- How do we include the direction of text display in HTML?
- How to include an acronym in HTML?
- How to include an abbreviation in HTML?
- How to include another HTML file in an HTML file?
- How to include an input field in HTML?
- How do we create an image map in HTML?
- How do we send an email using HTML forms?
- How do we define an area in an image map with HTML?
