Hey! No arguing with John Resig around here ;) But the script tag thing is a templating solution - so the advantage is obvious: having to maintain a 10kb+ HTML fragment encoded as a JavaScript variable (or even comprised of jQuery statements) is not fun.
I'm not a fan of the script type="text/html" method myself, and if i have to do client-side templates I prefer to have it as a hidden element or in a hidden textarea. But these get read by screen readers and Google, unlike the script tag method. I'm not sure why the poster needs to access that DIV via a script tag, but as its type is FBML - I'm guessing they got stuck implementing some dodgy Facebook app... ergh. So, best of luck to him/her! On Sep 10, 1:59 pm, RobG <robg...@gmail.com> wrote: > On Sep 10, 9:49 am, Mr Speaker <mrspea...@gmail.com> wrote: > > > I think it's perfectly valid to have a div inside a script tag (or at > > It is never valid markup in an HTML document, a div element can't be a > child of a script element. > > > least useful), if a div makes sense to the TYPE you defined for the > > script. > > If you want to discuss HTML markup, then an HTML group would be a much > better place to do that: > > <URL:http://groups.google.com/group/comp.infosystems.www.authoring.html/br... > > > > The content of a script element is not considered markup, it is > script. > > > For example, John Resig uses a script tag with type "text/ > > html" in his micro-templating > > solution:http://ejohn.org/blog/javascript-micro-templating/ > > I think that is a very bad idea for a web page. What advantage does > that approach have to assigning the string to a variable and using a > script language that the browser understands? > > He demonstrates that a script element can contain random text, and > sets a trap for any browser that dares to be standards compliant and > end the script element at the first occurrence of </. > > > In this instance though (and in reply to the original author) you add > > an ID to the SCRIPT tag, > > While browsers tolerate that, it is invalid markup. > > -- > Rob