Home

linkelement

The link element is an HTML element used to declare a relationship between the current document and an external resource. It is an empty element that does not render content and is most often placed in the head section of a document. Its primary purpose is to link the document to metadata or resources such as stylesheets, icons, and preloaded assets, rather than to create visible content.

Common attributes include href, rel, and as. The href attribute specifies the URL of the resource. The

Typical uses encompass linking external stylesheets, declaring icons and favicons, providing canonical URLs, and issuing resource

Compared with the anchor element, which creates navigable links in the document body, the link element conveys

rel
attribute
defines
the
relationship
type,
such
as
stylesheet
for
CSS
files,
icon
for
favicons,
canonical
for
search
engine
optimization,
or
preload
for
resource
hints.
The
as
attribute
is
used
with
certain
rel
values
(notably
preload
and
preconnect)
to
indicate
the
kind
of
resource
being
fetched,
which
helps
the
browser
optimize
loading.
Other
attributes
frequently
used
with
link
elements
include
type
(the
MIME
type),
media
(a
media
query),
integrity
(subresource
integrity),
crossorigin,
referrerpolicy,
sizes,
hreflang,
and
title.
hints
like
preload,
preconnect,
and
prefetch
to
improve
performance.
For
example,
a
stylesheet
might
be
linked
with
<link
rel="stylesheet"
href="styles.css">,
while
a
favicon
could
be
declared
with
<link
rel="icon"
href="favicon.ico"
sizes="16x16">.
A
preload
example
is
<link
rel="preload"
href="font.woff2"
as="font"
type="font/woff2"
crossorigin>.
metadata
and
resource
relationships
that
influence
how
the
document
is
fetched
and
processed
by
the
browser.