aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes textarea empty tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply locked New topic
Author

textarea empty tag

Babji Reddy
Ranch Hand

Joined: Jan 24, 2006
Posts: 106
When creating textarea in HTML tags, for initial time when I render the text area with closing </textarea> I am able to view the page fine

But when I remove </textarea> and have the empty text area as in second case, I am not able to view the page properly. (see the attachment, not sure whether the screen shot is attached, but if its not please take this HTML and run it )

Whats wrong with the <textarea/> code?



[Thumbnail for screenshot.png]

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61420
    
  67

It's not valid HTML.

HTML is not XML.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Babji Reddy
Ranch Hand

Joined: Jan 24, 2006
Posts: 106
But even making it as XHTML and now the code is like


And this is a valid XHTML according to the w3c validator http://validator.w3.org/

But I get the same result in IE 7and Firefox 3, but looked well in Chrome!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61420
    
  67

The browsers still do treat XHTML like XML. You'll need to use correct format or it just will not work.
Babji Reddy
Ranch Hand

Joined: Jan 24, 2006
Posts: 106
But why only textarea. I can see the other fields like input type='text' properly.

XHTML is supposed to be a standard that browsers adhere to and <textarea/> is a very valid XHTML tag.
Is this a bug in the browser?


Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61420
    
  67

They have no content. Ever. This also applies to other tags like <script>.

Bottom line is that you cannot use the self-closing syntax for tags that can have content.
Babji Reddy
Ranch Hand

Joined: Jan 24, 2006
Posts: 106
Then shouldn't this be an XHTML rule that <textarea/> is not a valid XHTML tag though its a valid XML tag?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61420
    
  67

What is valid XML or not is completely moot. We can discuss whether something should be valid or not until the cows come home.

The bottom line is what works in the browsers is what needs to be used. What doesn't, doesn't.
Babji Reddy
Ranch Hand

Joined: Jan 24, 2006
Posts: 106
Please see my other post
http://www.coderanch.com/t/453088/XML-Related-Technologies/XSLT-empty-tag
where I mentioned the problem why I cannot generate such tag.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61420
    
  67

Closing this topic so it can be discussed in one place.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: textarea empty tag