Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jun 2007
    Posts
    13
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Easy to read code vs IE spacing

    I like to try and indent and space out my code, to make it somewhat readable later. However, IE, and to a limited extent, firefox will sometimes add spaces to the page, usually messing up tightly fitting images and the like. Is there any way to stop that, besides getting rid of all spaces and indention, making the code one big horrible block? A very basic example would be as follows:

    Code:
    <div>
            <img src=whatever>
            <img src=whatever>
    </div>
    vs
    Code:
    <div><img src=whatever><img src=whatever></div>
    I've been working around it, but it is still a pain to read. Just wondering if there is a better way.

  • #2
    Senior Coder twodayslate's Avatar
    Join Date
    Mar 2007
    Location
    VA
    Posts
    1,042
    Thanks
    67
    Thanked 39 Times in 39 Posts
    I do not see why it would add a spacing.
    I indent my code and I do not see a problem, go with option one.
    twitter | Quality Hosting - $5.95/mo*
    Feel free to PM me!

  • #3
    New Coder
    Join Date
    Jun 2007
    Posts
    13
    Thanks
    4
    Thanked 0 Times in 0 Posts
    More specifically, here was the actual code that did this to me the most recently:

    Code:
    <div class='leftalign'><img src='images/menu.revisions.gif'><img src='images/menu.corrections.gif'></div>
    The images are 37 pixels high, so is the DIV they are in which has a 37px background. If I indent them as shown above, the DIV appears slightly taller in IE, causing the images to not line up, and the background to repeat vertically. Get rid of the spaces and it works fine, but the code is ugly to look at.

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    You can float the images to the left but then you would need to clear your floated images or you can set the line-height to something like 0 if there is to be no text in the div.
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •