View Source

According to Wikipedia, In the early Internet, the View Source technique helped people learn by example to create their own web pages. I think dinosaurs would've laughed their asses off about how we treat short-term evolution these days, but fine.

Firefox and Chromium based browsers still support the scheme. If you navigate to view-source:https://krijnhoetmer.nl/log/2026/04/view-source directly (or by using Ctrl+U, ⌘U or ⌥⌘U) you can still see the underwater screen.

You used to be able to link to the view-source URI scheme in those browsers, but due to security reasons, that has been removed from the web platform. Eric Lawrence has a nice write-up about some of the details. Showing your code, the easiest way to do, went the way of the dodo.

Imagine teaching others how to do things, by just linking to your own code. Like in the early Internet. Especially now you can link to text fragments, that would've been beautiful! Chromium based browsers strip the fragment identifier when viewing source, but in Firefox this works. What if instead of copying code, wrapping it in a <pre> element, formatting it nicely, escaping special characters, messing with overflow and adding syntax highlighting to your TODO list, you could just link to view-source:https://krijnhoetmer.nl/log/2026/04/spam-filtering#:~:text=%3Clabel%20for=%22comment-spam%22%3E,%3C/script%3E. Or am I the only person on this planet still caring about nicely indenting their HTML? Like a dinosaur right before some major extinction event.

Ok, maybe it's not the most user-friendly way of sharing code. But while writing this down, I learned a lot about text fragments. Half an hour ago I didn't know you could link to multiple fragments for example, or how prefixes and suffixes worked. So that's part of my day well spent, just by playing around with the view-source interface.

Another fun way to share your HTML code would be in a quine, by the way. Or this custom element I read about recently. Two of my inspirations for showing code and live demos in blog posts are Jake Archibald and Josh Comeau. One can dream, right?

Comments

I once used view-source as the only tool to figure out what the structure was of a website constructed from multiple layers of nested framesets. Took me a whole day.
But yeah, view source is still really nice. And your source looks nice (except for the style block, with the hard to read one-liners. Is that for performance? Hahaha). And if you want to use view-source as a teaching tool, maybe you could add some comments?

Add a comment