Get the latest tech news

HTML whitespace is broken (2024)


A deep dive into HTML whitespace collapsing: How it works, why it sucks, how it should work, and how to deal with it.

The css mode is actually a very useful middle ground for getting the nicer ignore formatting in at least most of the cases where it won't have any negative effects while still using strict where it's likely to be important. in conceivable!I don't see a good solution to that without completely reworking HTML's rendering model such that every tag has a statically-knowable formatting context, which is a much more complicated change to make. It does mean that in some situations you might have to exceed the line length limit, and potentially fight with your formatter (don't use--html-whitespace-sensitivity ignore), but I think it's worth it given how common of a foot gun this particular use case is.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of HTML Whitespace

HTML Whitespace