問題:
This question already has an answer here: 這個問題在這裏已有答案:
- How do I remove the space between inline-block elements? 如何刪除內聯塊元素之間的空格? 37 answers 37個答案
Is there anything in HTML/CSS that tells the browser to ignore whitespace completely? HTML / CSS中是否有任何東西告訴瀏覽器完全忽略空格?
So many times when you want to put, say, two images next to each other - you try desperately to keep the HTML readable, but the browser puts a space between them. 很多時候你想把兩個圖像放在一起 - 你拼命想讓HTML保持可讀性,但是瀏覽器會在它們之間留一個空格。
So instead of something like this: 所以不要這樣:
<img src="images/minithing.jpg" alt="my mini thing" />
<img src="images/minithing.jpg" alt="my mini thing" />
<img src="images/minithing.jpg" alt="my mini thing" />
<img src="images/minithing.jpg" alt="my mini thing" />
you end up with this 你最終得到了這個
<img src="images/minithing.jpg" alt="my mini thing" /><img src="images/minithing.jpg" alt="my mini thing" /><img src="images/minithing.jpg" alt="my mini thing" /><img src="images/minithing.jpg" alt="my mini thing" />
Which is just so horrible! 哪個太可怕了!
解決方案:
參考一: https://stackoom.com/question/B1fu參考二: Ignore whitespace in HTML [duplicate]