Whitespace runs collapse to one space, never to none
Most of what an HTML minifier throws away is whitespace, and the only interesting question is how far it goes. Strip every gap between tags and you get the smallest possible file. You also change what some pages say, because a space between two inline elements is rendered text. <b>a</b> <b>b</b> reads “a b”. <b>a</b><b>b</b> reads “ab”. Nothing in the markup flags which of those you meant.
The rule here is narrower on purpose. Inside a text node, a run of spaces, tabs, carriage returns, newlines and form feeds becomes exactly one space. Three spaces between two bold tags come out as one. Twelve lines of indentation in front of a paragraph come out as one. No gap inside the document ever collapses to nothing. Measured against a minifier willing to gamble, that is a byte lost per gap, and it is the entire safety margin.
There is one exception, and it lives at the two edges. The finished result is trimmed, so a fragment that started or ended with a space comes back without it. That is invisible in a whole document and occasionally matters in a snippet you are about to drop back between two inline elements, where you may need to type the space in again.
Two things deliberately survive the pass. A non-breaking space is a character somebody typed on purpose, so it sits outside the collapse and comes through intact even in the middle of a run. Whitespace inside a quoted attribute value survives too, because tags are copied out verbatim instead of being re-serialised, so alt="two spaces" keeps both of them.
Comments split into two classes. An ordinary comment is dropped. A conditional comment, meaning one whose body opens with [if or contains <
