I have a div full of images:
.species { background-color: lightblue; margin-top: 20px; display: inline-block; } .animals { display: inline; margin: 0; margin-right: 25px; margin-top: 5px; } .animal { width: 25px; padding: 8px 2px 0 2px; display: inline; }
<div class="species"> <div class="animals"> <img class="animal" src="ant.png"> <img class="animal" src="ant.png"> <img class="animal" src="ant.png"> <img class="animal" src="ant.png"> <img class="animal" src="ant.png"> <img class="animal" src="ant.png"> <img class="animal" src="ant.png"> </div> </div>
Since my content is well limited to 600px , a div ( .animals ) containing ant wraps looks like this:

But I want it to end as a <span> ending with the last ant, like this (created in the photo editor):

However, if I give the parent <div> built-in display or change it to span , the parent will not expand to the height images, so I get the following:

script example
So my question is: is it possible to get the best of both worlds here between div and span s, where is the container size for the height images but does not apply to the width page in the last line?
I tried various CSS commands to wrap text and spaces, but to no avail.
html css image
Chris wilson
source share