Textarea with/without doctype

I have a page which has textarea “height:100%” at http://form.kr/test01/without_docType.php

I like to put “doctype” in the page.

So I made another page at http://form.kr/test01/with_docType.php
but “height:100%” doesn’t work when I put “doctype”.

How can I make “height:100%” work with “doctype”?

You dont even have the most basic of correct html in either example. Start with that first.

How about this?
http://form.kr/test01/with_docType2.php

Assuming you want the text area to fill the entire page… (Why?)

<!DOCTYPE HTML>

<html>

<head>
  <title>Untitled</title>
  <style type="text/css">
  textarea {
  width: 100%;
  height: 100vh;
}
  </style>
</head>

<body>
<form>
<textarea> </textarea>
</form>

</body>

</html>

Thank you, benanamen

When textarea is full, it is, I think, easy to write a post both mobile and desktop, especially the text is long…

When you use percentage for height there must be something to base the percentage height on otherwise the height defaults to auto.

For height:100% to work there must be an unbroken chain of parents that also have height:100% defined all the way back to root (HTML).

Without a doctype the browser goes into quirks mode (which basically assumes that the author doesn’t know what they are doing) and will try and guess what you meant.

You should always have a doctyoe or browsers will make different assumptions about your code.

The vh unit is the modern way to get viewport height and needs no chain back to root. You will also need to negate margins on the body (and any parent wrappers) or the element will be taller than the viewport.

3 Likes

Hi Guys,

I found the solution,
please remove the type text property in text area its work both with/without doctype
From

<textarea type="text" style="width:100%;height: 100%;"></textarea>

To
<textarea style="width:100%;height: 100%;"></textarea>

Actually that is no the solution to the problem although you have pointed out an error. The display still won’t work unless the methods mentioned in my previous post are carried out.

Yes you should remove the type property from the textarea but is has no effect on the height issue that was mentioned.