Terence’s site works by delivering a document with a claimed MIME type of
text/html, but which contains only the (invalid) “HTML” code
<!doctype UNICODE><meta charset="UTF-8"><plaintext> (to work around browsers’ wish to treat the page as HTML). This is followed by a block of UTF-8 plain text making use of spacing and emoji to illustrate and decorate the content. It’s frankly very silly, and I love it.1
I think it’s possible to go one step further, though, and create a web page with no code whatsoever. That is, one that you can read as if it were a regular web page, but where using View Source or e.g. downloading the page with
curl will show you… nothing.
I present: The Page With No Code! (It’ll probably only work if you’re using Firefox, for reasons that will become apparent later.)
Once you’ve had a look for yourself and had a chance to form an opinion, here’s an explanation of the black magic that makes this atrocity possible:
- The page is blank. It’s delivered with
Content-Type: text/html. Your browser interprets a completely-blank page as faulty and corrects it to a functionally-blank minimal HTML page:
<html>elements can be styled with CSS; this includes the ability to add content:
::aftereach element. If only we could load a stylesheet then content injection is possible.
- We use the fourth way to inject CSS – a
Link:HTTP header – to deliver a CSS payload (this, unfortunately, only works in Firefox). To further obfuscate what’s happening and remove the need for a round-trip, this is encoded as a data: URI.
This is one of the most disgusting things I’ve ever coded, and that’s saying a lot. I’m so proud of myself. You can view the code I used to generate this awful thing on Github.
1 My first reaction was “why not just deliver something with
Content-Type: text/plain; charset=utf-8 and dispense with the invalid code, but perhaps that’s just me overthinking the non-existent problem.
10 replies to The Page With No Code
Some html for you page with no html.
This text is bold.
Sure thing, but this isn’t the page with no HTML. This is a blog post about the page with no HTML!
Lol, Firefox *barely* supports this. If you go into the inspector and try to get any information about the stylesheet that it loaded from the `link` header, it summarily crashes.
Strange! The inspector works fine for me! Tested using latest Firefox on Linux, Mac, and Windows.
@mikestreety this is horrifying and I love it
This Article was mentioned on mikestreety.co.uk
This Article was mentioned on old.reddit.com
Dear GOD/GODS and/or anyone else who can HELP ME (e.g. TIME TRAVELERS or MEMBERS OF SUPER-INTELLIGENT ALIEN CIVILIZATIONS):
The next time I wake up, please change my physical form to that of FINN MCMILLAN formerly of SOUTH NEW BRIGHTON at 8 YEARS OLD and keep it that way FOREVER.
I am so sick of this chubby Asian man body!
– CHAUL JHIN KIM (a.k.a. A DESPERATE SOUL)
[…] The Page With No Code – Dan Q […]