使用换行符时,删除HTML元素之间的空格 [英] Removing whitespace between HTML elements when using line breaks

查看:190
本文介绍了使用换行符时,删除HTML元素之间的空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大约有10行 img 的页面。为了HTML的可读性,我想在每个 img 标签之间放置一个换行符,但这样做会渲染图像之间的空格,我不想要。除了在标签的中间,而不是在标签之间,有什么我可以做的其他事情吗?

I have a page with a row of about 10 imgs. For readability of the HTML, I want to put a linebreak in between each img tag, but doing so renders whitespace between the images, which I do not want. Is there anything I can do other than break in the middle of the tags rather than between them?

编辑:这里是我迄今为止的截图。我想要的书脊图像显示在随机组合,使用PHP。这就是为什么我需要单独的 img 标签。

Here is a screenshot of what I have so far. I would like the book spine images to display in random combinations, using PHP. This is why I need separate img tags.

推荐答案

在图像上设置display:block或float:left将允许您定义自己的间距,并设置所需的HTML格式,但会以可能或不合适的方式影响布局。

You could use CSS. Setting display:block, or float:left on the images will let you have define your own spacing and format the HTML however you want but will affect the layout in ways that might or might not be appropriate.

否则,你正在处理内联内容,所以HTML格式很重要 - 因为图像将有效地像单词。

Otherwise you are dealing with inline content so the HTML formatting is important - as the images will effectively act like words.

这篇关于使用换行符时,删除HTML元素之间的空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆