The HTML <base> element
#TIL
I usually like to look at the HTML of web pages that get delivered to my browser window. Today, I noticed that all assets that were loaded relatively came from a different URL. Interesting huh! * OMG!! How did they do thaatt??*
HTML has a <base>
tag that specifies the base URL for all relative links in a web page. Well thought through, right? Definitely.
|
|
In this case, the css/main.css
would resolve to base-path/css/main.css
. Nifty!
Wait, there’s more! the <base>
tag can define what target
links would generally open in. So, next time you want all links to open in a new tab, don’t mess with all links but instead add the following to the <head>
|
|
Check out the MDN docs for more details.
Fin. Das ist alles.