TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

When does white space matter in HTML? (2016)

61 点作者 bradyholt将近 7 年前

6 条评论

lolc将近 7 年前
Funnny how I hesitated clicking the link because part of my brain insisted that whitespace in HTML was "boring". Not worth of consideration. I'm glad I did click in the end becaus this article summarily answered a host of questions I'd collected over the years. I have a much clearer model now.
CM30将近 7 年前
Who actually thought rendering the white space between inline-block elements was a good idea in the first place?<p>Seriously, I genuinely cannot see a use case where this setup would make things better, and it&#x27;s quite clear that in 95% of them it just makes things harder for web developers. Pretty much no one uses this to align anything, and any use cases I can see could be done better with margins.<p>Just ignore the spaces between inline-block elements and instruct browsers to strip them out.
评论 #17637858 未加载
评论 #17639670 未加载
foolip将近 7 年前
It doesn&#x27;t matter, but couldn&#x27;t help but notice that the honorable form feed (U+000C) was missing from the definition given. <a href="https:&#x2F;&#x2F;infra.spec.whatwg.org&#x2F;#ascii-whitespace" rel="nofollow">https:&#x2F;&#x2F;infra.spec.whatwg.org&#x2F;#ascii-whitespace</a> is the concept used in the HTML parser. (<a href="https:&#x2F;&#x2F;html.spec.whatwg.org&#x2F;multipage&#x2F;parsing.html" rel="nofollow">https:&#x2F;&#x2F;html.spec.whatwg.org&#x2F;multipage&#x2F;parsing.html</a>)
z3t4将近 7 年前
I just hate when the web browsers renders differently depending on if you have a line break between certain elements. Line breaks in HTML source code should not matter!
评论 #17635745 未加载
评论 #17634856 未加载
Theodores将近 7 年前
As of 2018 there is no neat helpful way of resolving white space problems that I know of in Chrome devtools. I wish there was as I can remember trying to get the white space removed from a search box and the search submit button, almost getting into the realms of hacky negative margin things before the penny dropped that it was the white space problem that I had known since the IE6 days.<p>If using code to generate HTML then you can remove white space with Google&#x27;s mod_pagespeed. This will only remove a certain amount and what remains either &#x27;doesn&#x27;t matter&#x27; or is something that needs fixing in templates.<p>I doubt there is a performance penalty for excessive white space but it is satisfying to be able to &#x27;view source&#x27; for the document to be pretty printed with the exception of indentation. In my opinion source documents should be neat, otherwise might aw well just give up on HTML and go for some byte code HEX digit stream in a non-human-readable format.
hsivonen将近 7 年前
Also fun: whitespace after &lt;&#x2F;body&gt;