Summary
HTML Minifier removes meaningful whitespace inside elements whose text content is whitespace-sensitive. This changes the rendered/content value instead of only removing formatting between tags.
Reproduction
- Open
https://byteflow.tools/en/html-minifier.
- Paste:
<pre> a b
c </pre>
<textarea> x y </textarea>
<div> spaced text </div>
- Click Minify.
Actual output
<pre> a b c </pre><textarea> x y </textarea><div> spaced text </div>
The two spaces, repeated spaces, and newline inside <pre> are lost. The repeated space inside <textarea> is also lost.
Expected output
Whitespace inside <pre> and <textarea> should be preserved, while whitespace between tags may be minified. For example:
<pre> a b
c </pre><textarea> x y </textarea><div> spaced text </div>
Impact
Minifying markup containing code samples, preformatted text, or user-editable textarea content changes the content semantics and can corrupt the displayed or submitted value. The page documentation also says to preserve semantics in <pre>, <code>, and inline text.
Environment
Summary
HTML Minifier removes meaningful whitespace inside elements whose text content is whitespace-sensitive. This changes the rendered/content value instead of only removing formatting between tags.
Reproduction
https://byteflow.tools/en/html-minifier.Actual output
The two spaces, repeated spaces, and newline inside
<pre>are lost. The repeated space inside<textarea>is also lost.Expected output
Whitespace inside
<pre>and<textarea>should be preserved, while whitespace between tags may be minified. For example:Impact
Minifying markup containing code samples, preformatted text, or user-editable textarea content changes the content semantics and can corrupt the displayed or submitted value. The page documentation also says to preserve semantics in
<pre>,<code>, and inline text.Environment