I'm working on setting up a website using pretty straightforward HTML/CSS. The one slightly tricky thing I am doing involves the <base>
tag. I want to be able to load my website pages both on my local filesystem (so I can test the website locally easily, before uploading it) and of course from my actual website. So in my <head>
tag I put something like:
<base href="." />
or
<base href=".." >
The purpose of this tag is to make the base URL for the page be the root page for my website, whether I'm looking at the page locally or over http:. Then my URLs are always relative to that root; to link to a page called "support.html" that is located in the root directory of my website I can just do href="support.html"
, to link to an image in an "images" directory inside that root directory I can do "images/myimg.jpeg".
This works great. I have uploaded my website to my server, and I can browse my pages and follow the links using Safari, Chrome, and Firefox; all three browsers seem to have no problem with the way I'm using the <base>
tag. At the same time, I can open one of my .html files directly from the filesystem on my local machine, and see everything fine. As far as I can tell, what I'm doing is perfectly legal HTML, just perhaps slightly unconventional.
But the W3C Link Validator doesn't seem to think so. It barfs all over the place with errors like:
Line: 208 /developer.html
Status: 400 URL must be absolute
This is usually the sign of a malformed URL that cannot be parsed by the server. Check the syntax of the link.
Note that at line 208 the link given is <A HREF="developer.html" target="_blank">
; the W3C validator appears to have incorrectly prepended a leading / onto it, rather than using the base URL given in the page.
So my question is: is the W3C Link Validator simply wrong? Is it too dumb to understand <base>
tags even though they are legal HTML? Or is there, in fact, something wrong with what I am doing, such that I need to fix my pages (even though they work fine in all the browsers I've tried)?
Note that these are not just warnings. They are preventing the W3C Link Validator from correctly testing my page's links. There is, in fact, a bad link on the page, but the validator does not find it, because it is too wrapped up in these "URL must be absolute" issues to correctly test the links.
Thanks! Oh, and if it matters, this is DTD HTML 4.01 Transitional.