Forum Moderators: not2easy

Message Too Old, No Replies

textarea {height: 100%} in ie strict mode

         

nwall

8:40 am on Mar 30, 2005 (gmt 0)

10+ Year Member



with the following code the textarea doesn't fill the div in IE, although it will stretch to fill the div in both quirks mode and firefox. anyone know a solution to this other than switching back to quirks mode?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head><title></title>

<style type="text/css">
div {width: 400px; height: 400px; border: 1px solid #000000}
textarea {width: 100%; height: 100%}
</style>

</head><body>

<div><textarea></textarea></div>

</body></html>

Longhaired Genius

10:22 pm on Mar 30, 2005 (gmt 0)

10+ Year Member



Your markup is not valid. Size of textarea is defined in rows and columns, not width and height.

nwall

10:33 pm on Mar 30, 2005 (gmt 0)

10+ Year Member



but i want to define it in width and height. as i said, it works fine in firefox and ie quirks, so i really don't see why ie strict would ignore my height setting, whether or not w3c wants to complain that i didnt set cols and rows properties. furthermore, ie strict couldn't care less that i used css width rather than xhtml cols, so why would it care so much that i specify rows rather than height?

since it seems noone has a really good answer to this question, i'll try asking another one. is there any way to force ie into quirks mode for just the textbox or some other type of hack i could do to just get it to work? short of setting the whole document to quirks mode, that is.

Longhaired Genius

10:37 pm on Mar 30, 2005 (gmt 0)

10+ Year Member



As you're composing your own personal markup, of course you should not use a strict doctype. It's a question we all face to a greater or lesser degree every day.

nwall

10:41 pm on Mar 30, 2005 (gmt 0)

10+ Year Member



i will gladly take the DTD out for IE pages if there is another way to force IE out of quirks mode and still resize the textbox to 100% height.

nwall

11:31 pm on Mar 30, 2005 (gmt 0)

10+ Year Member



i ended up solving this problem by putting the textarea in a seperate page and showing the textarea within an iframe. this way you can exclude the DOCTYPE on just that iframe, thus not breaking IE's quirks mode, so
textarea {width: 100%; height: 100%}
displays as expected, while still keeping box mode with the main content of the page.

thought i'd post this so it'd show up in google, etc in case someone else came across this problem.

here's the code:


<!-- IE quirks mode is needed to set a textarea's height to 100% -->
<html>
   <head>
      <title></title>
      <style type="text/css">
         html, body, div, #pagetext {width: 100%; height: 100%; padding: 0; margin: 0}
         body {overflow: hidden}
         #pagetext {border-width: 0; border-style: none}
      </style>
   </head>
   <body>
      <div>
         <textarea id="pagetext"></textarea>
      </div>
   </body>
</html>

then all you need is

<iframe src="..." />
in the place of where the <textarea> would normally be in the main page.