views:

778

answers:

3

I am getting a really strange behaviour when viewing a very simple piece of HTML in IE, served up by IIS. I am at a loss to explain this...

Take the following html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;

<html>
  <head>
    <style>
      .iWantaBorder
      { 
        border:red solid 1px ;  
      }
    </style>
  </head>
  <body>
    <select class="iWantaBorder">
  <option>1</option>
    </select>
  </body>
</html>

Save as html file to your desktop. When viewed in IE8, the select menu has a red border.

Now copy the file to a website or virtual directory in IIS 5.1 or IIS6.

Browse to that file in IE8... no red border.

Can anyone tell me what is going on here? I really want a border on this menu. Thought this should be simple to be honest, but I'm pretty much confused!

A: 

Try this:

border: 1px solid red;

The border shorthand syntax should be weight, style, colour. You appear to have this in the wrong order.

Putting these in the wrong order might put IE8 into quirks mode, possibly causing your problem.

ILMV
no joy there either fella. This is a really odd one.
Paul
A: 

This might fix the issue:

 <style type="text/css">
      .iWantaBorder
      { 
        border:solid 1px red;
        display:inline-block; /*this should fix the bottom and right border*/
      }
</style>

EDIT:

I have tried replicating the issue, you are right it doesn't work on IE8 but if you are on IE8 Standards/Compatibility mode it works on IE7 Standards/QuirksMode it does not, don't know why it's not working on IE7 Standards/Quirksmode.

Anyway another workaround is to wrap the select element with another inline element and put the border on wrapper element.

<span class="iWantBorder">
   <select>
      <option>Sample Option</option>
   </select>
</span>
jerjer
have tried 3 different document types and all manner of css including not using any shorthand.no joy...
Paul
have you tried adding type on style tag?
jerjer
good point, try <select style="border: 1px solid red;">
ILMV
certainly have...
Paul
please see my updated post
jerjer
I've tried adding the style directly to the element too...
Paul
+2  A: 

try putting this in your HEAD tag:

<meta http-equiv="X-UA-Compatible" content="IE=100" >

as per: http://msdn.microsoft.com/en-us/library/cc288325%28VS.85%29.aspx

Dave Markle