6

Consider these two lines:

<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="Content-Style-Type" content="text/css" />

From the W3's documentation on Scripting, in the section The default scripting language:

Authors should specify the default scripting language for all scripts in a document by including the following META declaration in the HEAD

Yet it continues in Local declaration of a scripting language to say:

The type attribute must be specified for each SCRIPT element instance in a document. The value of the type attribute for a SCRIPT element overrides the default scripting language for that element.

Seems to me like there's an over-specification here. Why are both the meta and per-script type declarations required? What's the point of a mandatory default if we 'must' declare each tag individually anyway?

Either let the default be the default, or just state that each tag needs it's own type - or is the wording here just getting me tripped up? The same language is used with reference to style sheets as well.

zb226
  • 9,586
  • 6
  • 49
  • 79
Chris Tonkinson
  • 13,823
  • 14
  • 58
  • 90
  • Just to clarify specific of W3C's way of doing technical documentation. According to this http://www.w3.org/2001/06/manual/#RFC they have specific meaning for key words to Indicate Requirement (e.g., "MUST", "MUST NOT", "REQUIRED") [[KEYWORDS RFC](http://www.ietf.org/rfc/rfc2119.txt)]. **SHOULD** This word, or the adjective "RECOMMENDED", mean that there may exist valid reasons in particular circumstances to ignore a particular item... **MUST** This word, or the terms "REQUIRED" or "SHALL", mean that the definition is an absolute requirement of the specification. – tyger Mar 21 '15 at 15:50

1 Answers1

5

The <script> and <style> elements are only one way of adding scripting and styling to HTML.

For scripting, we have event handler attributes, for styling HTML 4.01 defines the <link> element, the Link: HTTP header and the "style" attribute. In each of these cases, specifying the language is not mandated, so the fall-back would be the value of Content-Script-Type and Content-Style-Type.

For example: the scripting section says:

Documents that do not specify default scripting language information and that contain elements that specify an intrinsic event script are incorrect. User agents may still attempt to interpret incorrectly specified scripts but are not required to. Authoring tools should generate default scripting language information to help authors avoid creating incorrect documents.

and the styling section has an equivalent statement:

Documents that include elements that set the style attribute but which don't define a default style sheet language are incorrect. Authoring tools should generate default style sheet language information (typically a META declaration) so that user agents do not have to rely on a default of "text/css".

Note that these requirements are not DTD expressable, so validators that rely on a DTD won't flag violations as errors.

Whether any browser actually pays any attention to the settings, I've no idea.

Alohci
  • 78,296
  • 16
  • 112
  • 156
  • So the case you're making is that the Content-X-Type declarations are only meant for cases where type='Y' isn't available? That currently only applies to the `style` attribute (as the HTTP Link header (to my knowledge) is not even yet an RFC). I still don't see why type='Y' is necessary when you've defined a Content-X-Type default. – Chris Tonkinson Jun 13 '11 at 12:31
  • To answer your second point first, I guess it's an additional stronger restriction for ` – Alohci Jun 13 '11 at 13:10
  • 1
    @Chris - It's not just the "style" attribute. "onload", "onclick" etc can't have scripting language defined by any other means. `` (definitely) and `Link:` (probably) can name a style language to use, but there is no **must** or **should** level requirement for their use. – Alohci Jun 13 '11 at 13:14
  • @Chris - The most recent RFC for the HTTP Link header appears to be [RFC 5988](http://tools.ietf.org/html/rfc5988). It's at PROPOSED STANDARD state. – Alohci Jun 13 '11 at 14:54
  • I over-read the spec - good call, the `Content-X-Type` declaration is a "should" and not a "must" meant to handle as you say `onclick`s, etc. I guess it still seems pointless that I "must" specify the `type` when I "choose" to supply the `Content-X-Type` but now I understand much more clearly the meaning, purposes, and differences of the two specs. Thanks! – Chris Tonkinson Jun 13 '11 at 17:54