The HTML <a> Element

Publish in HTML Tutorial el 23/05/2025 14:41

The <a> (anchor) element is one of the most commonly used elements in HTML. It defines a hyperlink that links one page to another, either within the same website or externally. The most common attribute used with <a> is href, which specifies the URL of the page the link goes to. Additional attributes like target, download, and event handlers like onclick allow further customization.


Here’s how the anchor tag is typically defined:


And this is how it appears when rendered:

Play Code


This example shows a simple link to an external website.

Play Code


This example demonstrates using the download attribute to trigger a file download.

Play Code


This example uses an onclick event to trigger an alert using JavaScript.

Play Code


This example prevents the default link behavior and logs a message to the console.

Play Code


This example creates an internal page anchor using an ID.

Play Code

También te puede interesar

HTML <style> Element
HTML <style> Element

The <style> HTML element contains style information for a document, or part of a document. ...

HTML <strong> Element
HTML <strong> Element

The <strong> element is used to indicate that its content has strong importance, seriousnes...

HTML <span> Element
HTML <span> Element

The <span> element is an inline container used to mark up a part of a text or document. Unl...

HTML <source> Element
HTML <source> Element

The <source> element is used to specify multiple media resources for media elements like &l...

HTML <small> Element
HTML <small> Element

The <small> element is used to represent side-comments and small print, typically for discl...

HTML <section> Element
HTML <section> Element

HTML <section> Element: The Complete Guide The <section> element is a semantic HTML ...