Ok: Answer the question.
Where, in the head or the body of a HTML page, should you
NOT place a <SCRIPT...></SCRIPT> statement, and why?
The DTDs for HTML define the permissible document structures, at least
to the extent that DTDs can express constraints. The DTDs are part of
the specification.
Forget the ordering stuff - that's plain and understood.
can you for example nest a <SRIPT> statement inside say
a <DIV> stament?
Yes, but not necessarily in all nested contexts. SCRIPT elements can be
direct children of DIV elements, and other elements that may be
children, or descendants, of DIV elements can also contain SCRIPT
elements as their children, but not all elements that may be children or
descendants of DIV elements may have SCRIPT elements as their children.
And, as usual, actual browsers (may) tolerate more than is valid by
specification, but how much more is uncertain, inconsistent and
unpredictable.
Lik this
<DIV <SCRIPT></SCRIPT>> </div>
The pertinent definition from the (HTML 4.01 strict) DTD reads:-
| <!ELEMENT DIV - - (%flow
* -- generic language/style container -->
| <!ATTLIST DIV
| %attrs; -- %coreattrs, %i18n, %events --
| %reserved; -- reserved for possible future use --
| >
- and so the content of DIV elements is specified as zero or more
occurrences of %flow. And %flow is defined as:-
| <!ENTITY % flow "%block; | %inline;">
- (an elemnt that is either %block or %inline) with %inline defined as:-
| <!ENTITY % inline
| "#PCDATA | %fontstyle; | %phrase; | %special; | %formctrl;">
- (one of; PCDATA, %fontstyle, %phrase, %special or %formctrl)and
%special as:-
| <!ENTITY % special
| "A | IMG | OBJECT | BR | SCRIPT | MAP | Q |
| SUB | SUP | SPAN | BDO">
- (any one of the listed elements including SCRIPT).
Thus SCRIPT elements are allowed to be the (direct) contents of DIV
elements.
You are wrong.
No statement about THAT in your precious citation
Except for an explicit and precise statement of valid document
structures found in the specified DTDs.
What about this ?
<FORM>
<SELECT>
<OPTION><SCRIPT></SCRIPT></OPTION>
</SELECT>
</FORM>
The DTD entry for OPTION is:-
| <!ELEMENT OPTION - O (#PCDATA) -- selectable choice -->
| <!ATTLIST OPTION
| %attrs; -- %coreattrs, %i18n, %events --
| selected (selected) #IMPLIED
| disabled (disabled) #IMPLIED -- unavailable in this context --
| label %Text; #IMPLIED -- for use in hierarchical menus --
| value CDATA #IMPLIED -- defaults to element content --
| >
- so the permissible content is PCDATA ("Zero or more parsed data
characters", in SGML terms), which precludes SCRIPT elements (and all
other mark-up elements as those are not data characters).
This is covered in the FAQ:-
<URL:
http://jibbering.com/faq/faq_notes/script_tags.html#hsPrCn >
Richard.