HTML <a> Merker
Voorbeeld
Skep 'n skakel na W3Schools.com:
<a href="https://www.w3schools.com">Visit W3Schools.com!</a>
Meer "Probeer dit self" voorbeelde hieronder.
Definisie en gebruik
Die <a>
merker definieer 'n hiperskakel, wat gebruik word om van een bladsy na 'n ander te skakel.
Die belangrikste kenmerk van die <a>
element is die
href
kenmerk, wat die skakel se bestemming aandui.
By verstek sal skakels soos volg in alle blaaiers verskyn:
- 'n Onbesoekte skakel is onderstreep en blou
- 'n Besoekte skakel is onderstreep en pers
- 'n Aktiewe skakel is onderstreep en rooi
Wenke en notas
Wenk: As die <a>
merker geen
href
kenmerk het nie, is dit slegs 'n plekhouer vir 'n hiperskakel.
Wenk: 'n Geskakelde bladsy word gewoonlik in die huidige blaaiervenster vertoon, tensy jy 'n ander teiken spesifiseer.
Wenk: Gebruik CSS om skakels te styl: CSS-skakels en CSS-knoppies .
Blaaierondersteuning
Element | |||||
---|---|---|---|---|---|
<a> | Yes | Yes | Yes | Yes | Yes |
Eienskappe
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 |
Globale eienskappe
Die <a>
merker ondersteun ook die Global Attributes in HTML .
Gebeurtenis eienskappe
Die <a>
merker ondersteun ook die gebeurteniskenmerke in HTML .
Meer voorbeelde
Voorbeeld
Hoe om 'n prent as 'n skakel te gebruik:
<a href="https://www.w3schools.com">
<img border="0" alt="W3Schools"
src="logo_w3s.gif" width="100" height="100">
</a>
Voorbeeld
Hoe om 'n skakel in 'n nuwe blaaiervenster oop te maak:
<a href="https://www.w3schools.com" target="_blank">Visit W3Schools.com!</a>
Voorbeeld
Hoe om na 'n telefoonnommer te skakel:
<a href="tel:+4733378901">+47 333 78 901</a>
Voorbeeld
Hoe om na 'n ander afdeling op dieselfde bladsy te skakel:
<a href="#section2">Go to Section 2</a>
Voorbeeld
Hoe om na 'n JavaScript te skakel:
<a href="javascript:alert('Hello World!');">Execute JavaScript</a>
Verwante bladsye
HTML-tutoriaal: HTML-skakels
HTML DOM verwysing: Ankervoorwerp
CSS-tutoriaal: Stileerskakels
Verstek CSS-instellings
Die meeste blaaiers sal die <a>
element met die volgende verstekwaardes vertoon:
a:link, a:visited {
color: (internal value);
text-decoration: underline;
cursor: auto;
}
a:link:active, a:visited:active {
color: (internal value);
}