You can use newline characters in URLs

30 points by raymii 15 hours ago on lobsters | 1 comment

chrismorgan | 10 hours ago

Surprisingly not linked: URL Standard.

I would not recommend this as a general practice: it’s very fragile.

  1. If indentation is changed from tabs to spaces, your link may break because spaces in the middle of a URL aren’t skipped (though they are at the start and end).

  2. Although the trick works in HTML attribute syntax, it doesn’t work in various other contexts:

    a. In XML syntax, attribute-value normalisation turns those ASCII tabs and newlines into spaces, which aren’t skipped. (You need to use character references like  to get actual tabs and newlines—and they can actually be useful, e.g. in the HTML title attribute.)

    b. In CSS and JS, you have to add a trailing \ to allow line breaks in strings (and then the line break is removed—you’ll need the likes of \A in CSS and \n in JS to actually insert a carriage return).

As for data: URIs, those shown aren’t even really depending on this stripping behaviour, their contents don’t mind extra ASCII whitespace. I’ve definitely written data:image/svg+xml,… URLs on multiple lines before, but then concatenated them once I’m done tweaking it, since it’s probably in CSS I’m using it.