Results 1 to 8 of 8

Thread: Very Simple Image Problem.

  1. #1
    Join Date
    Jul 2007
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Very Simple Image Problem.

    I have very simple question about two images. When i put two images like this:

    HTML Code:
    <a href="#"><img src="pic.jpg" widht="24px" height="68px" border="0" align="top"></a>  
    <a href="#"><img src="pic2.jpg" widht="24px" height="68px" border="0" align="top"></a>
    and when i preview it, it shows little space between images.


    How i can delete that space? I mean it shows images like this:


    Thank you if you help

  2. #2
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Here's a hint.
    Code:
    /a>[GAP BETWEEN THE <a> TAGS]  [END Of GAP]


    Try removing it.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    In HTML, a line break in the code acts like a space on the page.

    ....</a><a href......
    Rather than:
    ....</a>
    <a href...
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Only when adjacent to text. All white-space between two tags is ignored. If I remember correctly, white-space between tags and text should be ignored as well, but in practice most browsers display white-space that comes before a closing tag that's after text.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    You can also use css to clear any margin/padding space that might be there (inhereted from other elements).

    HTML Code:
    <a href="#"><img src="pic.jpg" style='width:24px;height:68px;border:none;margin:none;padding:none;' align="top"></a>  
    <a href="#"><img src="pic2.jpg" style='width:24px;height:68px;border:none;margin:none;padding:none;' align="top"></a>
    Last edited by Twey; 07-29-2007 at 06:02 PM. Reason: Fixed typo ("marign")

  6. #6
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    And actually, you can replace the align="top" with CSS too. The images also require alt attributes in order to be standard, but that's beside the point.
    Thou com'st in such a questionable shape
    Hamlet, Act 1, Scene 4

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    My connection is being really weird, so I can't seem to upload a demo page, but there is very clearly a difference between these two blocks of code, Twey:
    Code:
    <img src="test.jpg" width="200" height="200">
    <img src="test.jpg" width="200" height="200">
    
    
    <img src="test.jpg" width="200" height="200"><img src="test.jpg" width="200" height="200">
    Just like letters in text, each image is an object, so whitespace between tags does affect the layout.

    I have no clue what the actual standards are, but in reality, that's what happens.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  8. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by Twey View Post
    Only when adjacent to text. All white-space between two tags is ignored. If I remember correctly, white-space between tags and text should be ignored as well, but in practice most browsers display white-space that comes before a closing tag that's after text.
    Quote Originally Posted by djr33 View Post
    My connection is being really weird, so I can't seem to upload a demo page, but there is very clearly a difference between these two blocks of code, Twey:
    Code:
    <img src="test.jpg" width="200" height="200">
    <img src="test.jpg" width="200" height="200">
    
    
    <img src="test.jpg" width="200" height="200"><img src="test.jpg" width="200" height="200">
    Just like letters in text, each image is an object, so whitespace between tags does affect the layout.

    I have no clue what the actual standards are, but in reality, that's what happens.
    djr33 is right. Inline elements like span or img will show a space if they are on separate lines in the source code:

    HTML Code:
    <span>a</span>
    <span>b</span>
    But not when they are on the same line:

    HTML Code:
    <span>a</span><span>b</span>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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