2

I am rewritting a client web page and I have some problems with HTML rendering.

Next code is the old HTML and all "a" and "img" tags are in one line like this (INLINE IMG):

<div id="inside-img">
    <div class="img" style="width:8643px"><a href=""><img src=""/></a><a href=""><img src=""/></a>... ...</div>
</div>

When I rewrite this, with better indentation like this (INDENTED IMG):

<div id="inside-img">
    <div class="img" style="">
        <a href=""><img src=""/></a>
        <a href=""><img src=""/></a>
        ...
   </div>
</div>

The output of HTML breaks as you can see in the image that I have attached.

There are a lot of images and the last image, moves down instead of be at the end of timeline. I do not know why when I indent HTML, HTML style change.

html_differences

Iker Ocio Zuazo
  • 331
  • 4
  • 13

2 Answers2

3

It seems a problem related to elements set to display as inline-blocks, which accounts for whitespace. While the OP does not provide any CSS associated to the markup, this should work:

<div id="inside-img">
    <div class="img" style="font-size:0;">
        <a href=""><img src=""/></a>
        <a href=""><img src=""/></a>
        ...
   </div>
</div>

or this (note the extra comments)

<div id="inside-img">
    <div class="img" style="">
        <a href=""><img src=""/></a><!--
        --><a href=""><img src=""/></a><!--
        -->...
   </div>
</div>

For a full explanation see https://css-tricks.com/fighting-the-space-between-inline-block-elements/

pecus
  • 351
  • 3
  • 8
2

This happen because of white space between inline items. White space between inline item in HTML gets visible on screen.As image is an inline item then your first code sample is not having any space between HTML tags. while in second sample code their is space between them ( new line) this will appear as a character (i.e. space) in HTML.

Possible solution for this is using Font-size: 0; on the parent div.

Master.Deep
  • 792
  • 5
  • 20