Subdomain relative url

I am huge fan of relative URLs. I am never sure about composition of my page so it helps moving it here and there.

Full URL looks like this:

https://user:pass@www.fantatec.com/path/path/document#location

We should not longer use user:pass@ in URL but note that @ and : character have their function already. 

There is a bunch of relative URLs possible. Sadly no subdomain relative URL. Lets take a look.

Relative Urls

See simplified version to inspect html source.

By location

Closest relative is location #by-location

Which requires adding id to some page elements.
One could consider adding id mark to every header in his page using a script. 

Here is an example script which does it.

This will soon no longer be required as browsers starts to support linking by text lookup.

By lookup

Links to first "lookup" text in current page:

#:~:text=lookup

See full documentation for lookups: https://developer.mozilla.org/en-US/docs/Web/Text_fragments#syntax

By Path

This is what most people call relative url. With path relative to current document.

By domain root

Relative to current domain, but search path starts from domain root.

By scheme/protocol

Can lead to different domain but using same protocol. Mainly to keep https or http.

Universe relative - absolute

The full url.

Subdomain relative

Currently there is no such approach in html. We can get it by some javascripting.
See this script

The * character not allowed domain character and is already used as wildcard domains.

The protocol could be skipped just like with scheme relative URL

Than we could add subdomain with dot.
//web.*/relative-urls.html

Repeating * would eat one subdomain up, just like .. does with path.

With double repeat two subdomains will be eaten.

And we could do same for images.


Thanks for free graphics from:
https://www.vecteezy.com/members/vectoroartworks

Comments