The anchor
element of HTML, representing the <a>
tag, supports the following attributes:
-
href
-
hreflang
-
referrerpolicy
-
rel
-
target
-
type
-
download
(as of HTML5)
As a curious fact, the title
attribute, which is widely used, does not appear in the current documentation.
There are other obsolete attributes such as: charset
To see the use of each of these attributes, you can consult the MDN documentation , which exists in Spanish.
To create a link you can simply do:
<a href="https://www.youtube.com">YouTube</a>
And within the% co_of opening% you can place one or more of the labels mentioned above.
Example:
<p>Sin nada:</p>
<a href="https://www.youtube.com">YouTube</a><br />
<p>Con título, usando la etiqueta <code>title</code> . Deja un momento el puntero sobre el enlace:</p>
<a href="https://www.youtube.com" title="Ir a Yo tuve :)">YouTube</a>
<p>Abrir enlace en otra página, usando la etiqueta <code>target</code>:</p>
<a href="https://www.youtube.com" title="Ir a Youtube :)" target="_blank">YouTube</a>
Regarding <a>
the documentation says the following:
Frequently abuse of anchor tags with the
Use of onclick
events to create pseudo-buttons by adjusting onclick
a " href
" or " #
" to prevent page reload.
These values cause unexpected behavior with links from
copied / drawn, opening links in new tabs / windows,
the saved of links (bookmarking), and when JavaScript is still
downloading, this throws errors, or is disabled. This too
leads to incorrect semantics for technologies of
assistance (eg, screen readers). In these cases,
recommends using a javascript:void(0)
instead. In general, you should only
use an anchor for navigation using a URL
adequate.
It should also be noted that the <button>
tag is not used only for links to external web pages using the <a>
protocol, but also for links on the same page using http
, as well as links to #seccion
addresses , to addresses of ftp
, to images, to telephone numbers. All this is detailed in the documentation (link above).