HTML atribut href


Definice a použití

Pro prvky a <a>atribut určuje adresu URL stránky, na kterou odkaz směřuje.<area>href

U <base>prvků hrefatribut určuje základní adresu URL pro všechny relativní adresy URL na stránce.

U <link>prvků hrefurčuje atribut umístění (URL) externího zdroje (nejčastěji souboru šablony stylů).


Platí pro

Atribut hreflze použít u následujících prvků:

Prvky Atribut
<a> href
<oblast> href
<základna> href
<odkaz> href

Příklady

Příklad

Atribut href určuje cíl odkazu:

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

Příklad oblasti

Obrazová mapa s klikacími oblastmi:

<img src="planets.gif" width="145" height="126" alt="Planets"
usemap="#planetmap">

<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" href="sun.htm" alt="Sun">
  <area shape="circle" coords="90,58,3" href="mercur.htm" alt="Mercury">
  <area shape="circle" coords="124,58,8" href="venus.htm" alt="Venus">
</map>

Základní příklad

Zadejte základní adresu URL pro všechny relativní adresy URL na stránce:

<head>
<base href="https://www.w3schools.com/images/">
</head>

Příklad odkazu

Odkaz na externí šablonu stylů:

<link rel="stylesheet" type="text/css" href="theme.css">

Podpora prohlížeče

Atribut hrefmá následující podporu prohlížeče pro každý prvek:

Element
a Yes Yes Yes Yes Yes
area Yes Yes Yes Yes Yes
base Yes Yes Yes Yes Yes
link Yes Yes Yes Yes Yes