'How to create a W3C-validation-link for local files?
I have some local (self generated) HTML files. I view them in browser via file://
without a local webserver.
I would like to have a link in the footer of each of this files to "Validate" them on the W3C Validator. On some websites I see the links like this in source
<p class="validation"><a href="https://validator.w3.org/check?uri=referer">Validate</a></p>
But of course this doesn't work because there is no referer about local files.
I was asking this on ProWebmaster but the question was out of scope there.
EDIT: File Upload to the validator website via its web formular is not an option. I would like to send the whole HTML source to the validator without any external tools.
<a href="https://validator.w3.org/check?content={self.source}">Validate</a>
Solution 1:[1]
You can't.
The was the referer link works is to tell the validation service to look at the Referer
header to get the URL to the previous page. Then to request that page and validate it.
Even if there was a Referer
header for your local file, there is no way for the validation service to access it. It would be a serious security problem if every website you visited could read files from your hard disk freely!
Use the file upload feature to validate files without a public URL.
Alternatively, consider using a local validation tool and possibly looking for an extension to your IDE that makes it more convenient to access (such as this extension for VS Code).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Quentin |