15

For my input, which can either have classname="half" or "half.not-placeholder-value", Firebug shows both inputs to have a set, fixed width of 25em.

input.half, input.half.not-placeholder-value {
    max-width: 25em;
}

Yet, according to Developer Tools, IE8 doesn't seem to use this particular max-width attribute. I say "doesn't seem to use" since Firefox's behavior differs with IE8 with respect to this attribute.

But the MDN docs say that IE7 supports max-width. Am I missing something?

7
  • I'm not sure max-width makes sense without any kind of variable width (such as width:100%) Jun 30, 2013 at 16:08
  • Hmm.. But, in Firefox, it creates a fixed length for my inputs - my desired behavior. Without max-width, the input sizes vary based on either class. Jun 30, 2013 at 16:09
  • Have you also tried adding the width: 100%; attribute just to see if it works? Jun 30, 2013 at 16:11
  • @RaphaelRafatpanah, I just tested "width:25em" and that worked in IE8, as well as Firefox. Jun 30, 2013 at 16:13
  • 1
    That will make all inputs 25em wide even if they could be smaller. If that is okay with you, great. If not, try width: 100%; max-width: 25em; Jun 30, 2013 at 16:17

2 Answers 2

25

This is not really an IE8 issue since IE8 does support the max-width attribute but only when given a defined width first.

input.half, input.half.not-placeholder-value {
    width: 100%;
    max-width: 25em;
}
2

Use IE8 css with width? First part targets IE, second part undoes it for IE9+.

input.half, input.half.not-placeholder-value {
    max-width: 25em;
    width:25em\9; /* IE 8 */
}
:root input.half, input.half.not-placeholder-value {
    width:inherit\9; /* IE 9+ */
}

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.