Home  >  Article  >  Web Front-end  >  How to Remove Spaces Between Inline Images Using CSS?

How to Remove Spaces Between Inline Images Using CSS?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-11-03 22:00:03678browse

How to Remove Spaces Between Inline Images Using CSS?

Removing Spaces Between Images Using CSS

The issue of space between images when displayed inline is a common concern. By default, browsers render any sequence of whitespace characters (spaces, tabs, newlines) as a single white space.

To eliminate this space, CSS offers a simple solution. By setting the display property of the image elements to block, you can force them to behave like block-level elements.

<code class="css">img {
  display: block;
}</code>

This CSS rule modifies the display behaviour of all images on the page, ensuring they appear on their own lines, eliminating any whitespace between them.

<code class="html"><div class="nospace">
    <img src="..." />
    <img src="..." />
</div></code>

With this CSS rule applied to the

containing the images, the code above will render the images side-by-side, without any space between them.

The above is the detailed content of How to Remove Spaces Between Inline Images Using CSS?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn