views:

131

answers:

4

Hello, I have some style like this:

<style type="text/css">
input[type=text]{
width:300px;
}
</style>

the above code works in chrome and firefox. Why not in IE? I am using this code in Reporting services at the end of Reports.aspx file.

+4  A: 

Which version of IE?

IE6 and lower do not support attribute selectors.

Just use a class, keep it simple:

input.text
{
   width:300px;
}

<input type="text" class="text" />
RPM1984
See http://caniuse.com/ for more detailed info.
nikc
@nikc - nice find, did not know about that site!
RPM1984
well, it's IE8 and as I wrote, maybe it's because I am using this code to customize textbox in reporting services?
niao
@niao - can you post the HTML please? also, use internet explorer developer tools (yuck, firebug FTW) to see what CSS is being applied? maybe something else is overriding it.
RPM1984
well, when I use simple input { width: 300px;} it works but I can't use this one because then all my inputs will be 300px width
niao
@niao - i didnt say use "input", i said apply a class to all input's that you want 300px, then style according to that (like in my answer).
RPM1984
yes but I can't apply class as the page is rendered by Reporting Services
niao
hmm, so you have no control over the HTML at all? kind of makes it difficult to apply CSS =). Can you paste a snippet of the rendered HTML? maybe there is a way we can apply a style based on the container of the input elements (e.g a DIV)
RPM1984
A: 

Double check that you don't have a space between the "input" and the "[". This burned me lately. Worked in FF/Chrome but not IE.

Damo
no, there is no space between them
niao
+3  A: 

It works fine in IE8, assuming the page is loading in IE7 or IE8 standards mode (not quirks)

Edit

You've said you're using IE8. In which case, use the developer tools (F12), locate your text box, and check what styles are being applied.

Edit 2

Don't know which version of reporting services you're using. Just went to a 2000 instance, and the report manager is serving up pages that render in quirks mode, so good luck getting much, if any, styling to work.

Edit 3

You may be able to force IE to render in IE8 mode by adding a meta tag to the head within the aspx pages. E.g. :

<head>
<meta http-equiv="X-UA-Compatible" content="IE=100" >
<!-- Rest of <head> -->
Damien_The_Unbeliever
I am using Reporting Services in 2005 instance
niao
@niao - the developer tools will tell you how IE is rendering the page you're trying to style. Hit F12, and in the menu bar it will display Browser Mode and Document Mode. I don't have a 2005 instance to play with, but I'm betting it'll be rendering in quirks mode also.
Damien_The_Unbeliever
yes, You are right. It renders in quirks mode. Can I change it somehow to render correct (in IE7 or IE8 standards mode?)
niao
@niao - again, I'm looking at a 2000 instance, not 2005. But I'm guessing the implementation is similar. I think you'd be looking at making changes to the aspx files themselves, and I'm not sure how far you could push it. Unless I've missed something somewhere along the way, there's no way to force it out of quirks mode purely from a CSS file. You might be able to add the meta UA-Compatible tag to the head and force the issue. http://msdn.microsoft.com/en-us/library/cc288325(VS.85).aspx
Damien_The_Unbeliever
A: 

Use the IE7-JS script. (It was originally created to add some features of IE7 to IE6, thus the name.)

It can add this feature to both IE6 and IE7. (Note that IE9.js is newest and it also fixes a bunch of other things in how IE interprets CSS.)

Venemo