views:

108

answers:

1

I have a simple page with a form and selects. Number of those selects are set invisible and I use Javascript (JQuery) to set visible/invisible the good one.

The CSS to set them invisible is :

select {
   margin:0;
   margin-top:5px;
   padding:0;
   border:0;
   }

.Invisible {
    display:none;
}

It works fine on Firefox, Opera and Chrome, but not, of course, on Internet Explorer 8.

It does render the selects invisible, but it reserves 1 or 2 pixels to each one.

Here is my test page

You can see that there is a big space between "Modèle" and "Budget" ... You can see it better if you play with the "Marque" dropdown.

+1  A: 

IE is rendering the space between your </select> and the next start <select> if your remove the newline and any space between these two elements, your mysterious spaces will go away.

Gordon Tucker
It works indeed ! Thanks ! I very surprised because I though that consecutives spaces not coded as " " were not rendered. Which the case in other browsers ...Is IE "wrong" or did I miss something ?
Jalil
I assume this is just a problem with IE. I had the same problem a year or two ago with a weird space between td tags in a table
Gordon Tucker
Jalil, consecutive whitespace characters (space, tab, newline) are not _eliminated_, they're collapsed to a _single_ whitespace separator when the HTML is rendered. http://www.w3.org/TR/html4/struct/text.html#h-9.1 has a hint: "...user agents should collapse input white space sequences when producing output inter-word space." The key here is 'producing output inter-word space', which implies the output still contains a space -- just not all the consecutive spaces contained in the input. Another hint is at http://www.w3.org/TR/xhtml-media-types/#compatGuidelines, in the Rationale under Sec. A5
Val
Thanks Val for your precision, I understand that. I tought that the invisible <select> WERE 'eliminated', like they were not there. So that all the 'inter-word spaces' between each invisible <select> where also collapsed into a single inter-word space. In fact, it seems that the others browsers consider it this way ...
Jalil