Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML minimization: whitespace around <li> should not be trimmed #643

Open
xuhdev opened this issue Nov 22, 2018 · 3 comments
Open

HTML minimization: whitespace around <li> should not be trimmed #643

xuhdev opened this issue Nov 22, 2018 · 3 comments

Comments

@xuhdev
Copy link

xuhdev commented Nov 22, 2018

The HTML minifier removes whitespace around <li> as a "blocked/undisplayed element":

.'|frame(?:set)?|h[1-6]|head|header|hgroup|hr|html|legend|li|link|main|map|menu|meta|nav'

However, <li> is commonly modified to be inline (e.g., "The Whitespace Issue" section here, tag clouds in WordPress themes Twenty Twelve and Twenty Seventeen). This often breaks the rendering of <li> elements.

@voku
Copy link

voku commented Nov 23, 2019

@xuhdev hi, can you please test the HtmlMin library for html compressing (https://github.com/voku/HtmlMin) or can you give me some example code (input + what you expected), thanks!

I am currently thinking of a pull request, so that we can use "HtmlMin" directly via this library, but first I wanted to know if this has some benefits for the users.

@picasticks
Copy link

@xuhdev just a comment, but li is a block-level element so it should be minified and all whitespace removed. This seems like not a bug.

One suggestion when you set li to display: inline like in your tag cloud example is to apply whitespace using margin/padding, or using pseudo elements. Here's an example of that:

li.inline {
  display: inline;
  list-style: none;
}
li.inline:after {
  content: ' ';
}

@hpvd
Copy link

hpvd commented Oct 12, 2020

I am currently thinking of a pull request, so that we can use "HtmlMin" directly via this library, but first I wanted to know if this has some benefits for the users.

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants