Balise HTML <a>


Exemple

Créez un lien vers W3Schools.com :

<a href="https://www.w3schools.com">Visit W3Schools.com!</a>

Plus d'exemples "Essayez-le vous-même" ci-dessous.


Définition et utilisation

La <a>balise définit un lien hypertexte, qui est utilisé pour relier une page à une autre.

L'attribut le plus important de l' <a>élément est l' hrefattribut, qui indique la destination du lien.

Par défaut, les liens apparaîtront comme suit dans tous les navigateurs :

  • Un lien non visité est souligné et bleu
  • Un lien visité est souligné et violet
  • Un lien actif est souligné et rouge

Conseils et remarques

Conseil : Si la <a>balise n'a pas d' hrefattribut, il s'agit uniquement d'un espace réservé pour un lien hypertexte.

Conseil : Une page liée s'affiche normalement dans la fenêtre actuelle du navigateur, sauf si vous spécifiez une autre cible.

Astuce : Utilisez CSS pour styliser les liens : CSS Links et CSS Buttons .


Prise en charge du navigateur

Element
<a> Yes Yes Yes Yes Yes

Les attributs

Attribute Value Description
download filename Specifies that the target will be downloaded when a user clicks on the hyperlink
href URL Specifies the URL of the page the link goes to
hreflang language_code Specifies the language of the linked document
media media_query Specifies what media/device the linked document is optimized for
ping list_of_URLs Specifies a space-separated list of URLs to which, when the link is followed, post requests with the body ping will be sent by the browser (in the background). Typically used for tracking.
referrerpolicy no-referrer
no-referrer-when-downgrade
origin
origin-when-cross-origin
same-origin
strict-origin-when-cross-origin
unsafe-url
Specifies which referrer information to send with the link
rel alternate
author
bookmark
external
help
license
next
nofollow
noreferrer
noopener
prev
search
tag
Specifies the relationship between the current document and the linked document
target _blank
_parent
_self
_top
Specifies where to open the linked document
type media_type Specifies the media type of the linked document

Attributs globaux

La <a>balise prend également en charge les attributs globaux en HTML .


Attributs d'événement

La <a>balise prend également en charge les attributs d'événement en HTML .



Plus d'exemples

Exemple

Comment utiliser une image comme lien :

<a href="https://www.w3schools.com">
<img border="0" alt="W3Schools" src="logo_w3s.gif" width="100" height="100">
</a>

Exemple

Comment ouvrir un lien dans une nouvelle fenêtre de navigateur :

<a href="https://www.w3schools.com" target="_blank">Visit W3Schools.com!</a>

Exemple

Comment créer un lien vers une adresse e-mail :

<a href="mailto:[email protected]">Send email</a>

Exemple

Comment créer un lien vers un numéro de téléphone :

<a href="tel:+4733378901">+47 333 78 901</a>

Exemple

Comment créer un lien vers une autre section sur la même page :

<a href="#section2">Go to Section 2</a>

Exemple

Comment créer un lien vers un JavaScript :

<a href="javascript:alert('Hello World!');">Execute JavaScript</a>

Pages connexes

Tutoriel HTML : Liens HTML

Référence HTML DOM : objet d'ancrage

Tutoriel CSS : styliser les liens


Paramètres CSS par défaut

La plupart des navigateurs afficheront l' <a>élément avec les valeurs par défaut suivantes :

a:link, a:visited {
  color: (internal value);
  text-decoration: underline;
  cursor: auto;
}

a:link:active, a:visited:active {
  color: (internal value);
}