This may be a stupid question, but if there is a better or better way to do this, I would like to study it.
I came across this several times, including recently, when small spaces appear in the displayed version of my HTML page. Intuitively, I think that they should not be, because outside the text or entities the formatting of the HTML page should not matter, but, apparently, it is.
I mean this - I have a Photoshop file from a client about how they want their site to look. They want it to look mostly a pixel, perfect for the image in this file.
One of the places on the page calls up the menu bar, where each of them changes the bit on hovering, acts as a hyperlink, etc. This is one long bar in the Photoshop file, so a cheap and easy way to do this is to simply divide this segment into several images and then place them next to each other in the file.
So instinctively I put it this way (there is more, but that's the point)
<a href="page1.html"> <img src="image1.png" /> </a> <a href="page2.html"> <img src="image2.png" /> </a> <a href="page3.html"> <img src="image3.png" /> </a>
etc.
The problem is that the images have this tiny space between them, which is unacceptable because the client wants this thing to be perfect for the pixel (and it just looks bad).
One way to get the correct display is to remove carriages between images
<a href="page1.html"> <img src="image1.png" /> </a> <a href="page2.html"> <img src="image2.png" /> </a> <a href="page3.html"> <img src="image3.png" /> </a>
Which makes the images go directly against each other (the desired effect), but it makes the line incredibly long and the code harder to maintain (it wraps here in SO and this is a simplified version - real long file names and JavaScript strewn to make it hang).
It seems to me that this should not happen, but it seems that the carriage return in HTML is treated as a small empty space. And this happens in all browsers, it seems.
Am I right or wrong in thinking that the two snippets above should do the same? And is there something I am doing wrong? Maybe save the file with the wrong encoding? Should I make each of these links a perfectly matched CSS element?