HTML formatter breaks layout by introducing newlines
See original GitHub issueMoved here from https://github.com/microsoft/vscode/issues/144042
Description
The HTML formatter breaks the layout of the page.
Input
The code looked like this before beautification:
<span>
<span>
<span>1:02</span
><time-dot>.</time-dot
><time-decimals>27</time-decimals>
</span>
</span>
Expected Output
The code should have looked like this after beautification:
<!-- no change? -->
<span>
<span>
<span>1:02</span
><time-dot>.</time-dot
><time-decimals>27</time-decimals>
</span>
</span>
Actual Output
The code actually looked like this after beautification:
<span>
<span>
<span>1:02</span>
<time-dot>.</time-dot>
<time-decimals>27</time-decimals>
</span>
</span>
This introduces newlines (and spaces) before and after the <time-dot>
element, which adds visual space between the elements on the page that was not there before:
Steps to Reproduce
Paste into https://beautifier.io/ or format in VSCode.
Environment
OS: N/A
Settings
Default?
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
HTML formatter breaks layout by introducing a newline #144042
This introduces newlines (and spaces) before and after the <time-dot> element, which adds visual space between the elements on the page that ...
Read more >The Dos and Don'ts of Adding an HTML Line Break
To do a line break in HTML, use the <br> tag. Simply place the tag wherever you want to force a line break....
Read more >How to prevent VS Code from breaking up long HTML lines ...
I am using prettier for formatting, and have set the printWidth option which works in javascript code, but for HTML it seems to...
Read more >How to Preserve Newlines, Line Breaks, and Whitespace in ...
Preserve Newlines, Line Breaks, and Whitespace in HTML. Use the white-space: pre; setting to display long-form content containing whitespace ...
Read more >Add a Line Break in HTML - Tutorial - TeachUcomp, Inc.
This tutorial shows you how to add a line break in HTML. By default, browsers ignore many formatting keystrokes that we take for...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@lgarron
This is good bug. Took me looking twice at the image, but that made it clear what the problem is. Thanks!
It appears that you want
<time-dot>
and<time-decimals>
to be treated as “inline” elements.However, the beautifier doesn’t do the end braces the way you said in your expected output. Once you made the elements “inline”, the expected output would be:
Question:
<time-dot>
and<time-decimals>
are not valid html elements. Where are you getting them?FYI: The bug template says:
I assume this means “do not submit screenshots without submitting associated text examples”, not “screenshots are forbidden, even if they illustrate the text examples”. Apologies if that’s not the case.