Home

rootrelative

Rootrelative is a term used in web development to describe a path or URL anchored to the root of the domain. A rootrelative path begins with a forward slash and resolves from the domain’s root directory, not from the current document location or a full external URL. For example, /images/logo.png is rootrelative; images/logo.png is relative to the current page, and http://example.com/images/logo.png is an absolute URL.

In practice, rootrelative paths are common in HTML, CSS, and templating to keep links portable across environments.

Behavioral note: the browser resolves a path starting with / against the domain root. The document’s subdirectory

Benefits include easier maintenance when switching domains or deploying across environments, and reduced risk of hard-coded

In
HTML,
you
might
reference
assets
with
src
or
href
attributes
starting
with
/.
In
CSS,
a
rootrelative
URL
looks
like
url('/images/bg.png').
Because
rootrelative
URLs
are
anchored
to
the
domain
root,
they
generally
remain
valid
when
the
site’s
domain
changes,
or
when
projects
move
between
environments
that
share
a
common
domain.
or
a
base
href
tag
can
affect
relative
URLs
that
do
not
start
with
a
slash,
but
rootrelative
paths
ignore
the
document’s
location
and
resolve
directly
from
the
domain
root.
hostnames.
Limitations
arise
when
a
site
is
served
from
a
subdirectory
or
behind
proxies,
where
resources
intended
for
a
subpath
are
expected
at
a
domain
root,
potentially
causing
404
errors.
In
such
cases,
developers
may
prefer
relative
paths
or
helper
functions
that
compute
appropriate
rootrelative
URLs
automatically.