w3c - How is "<" in HTML handled by browsers? -


in following snippet, < gets rendered expected in firefox 37.0.2 , have seen same in many other modern browsers well. textarea specification valid html5? ideally shouldn't &lt; escaping "<"

<html> <textarea> hello world < </textarea> </html> 

how html parsers distinguish between tag open , "<"? browsers lot handle errors automatically guessing, 1 such case?

the reason interested in because when use wysiwyg editors in web apps - save html editors source mostly. when template frontend, behaviour makes not mandatory html quote stuff backend. works without html quoting can cause undesired effects freezing / infinite loop's atleast tinymce editor's 3.5.8 version.

this indeed guessing. proper way use literal < in html use &lt; (and &gt; >).

that said, textarea bit specific in can never contain other html elements - parser can sure meant literal < , not starting tag. of course, breaks down </textarea> :)

from html 4 specification:

section 5.3.2:

authors wishing put "<" character in text should use "<" (ascii decimal 60) avoid possible confusion beginning of tag (start tag open delimiter). similarly, authors should use ">" (ascii decimal 62) in text instead of ">" avoid problems older user agents incorrectly perceive end of tag (tag close delimiter) when appears in quoted attribute values.

so it's not necessary html 4, it's still practice. , of course, xhtml , / or html 5 may bit more strict.

html specification quite non-specific in lot of things, goes long way ensuring browsers incompatible each other in (more or less) subtle ways. best bet not rely on things html allows, on explicit , specific. reason quite simple - 2 browsers can 100% compliant html specification, , still process same html in ways make useless.


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -