Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

Related: What's the point of Content-Script-Type and Content-Style-Type.

I wanted to know what the main reasons are that developers don't use

  • <meta http-equiv="content-script-type" content="text/javascript" /> and
  • <meta http-equiv="content-style-type" content="text/css" />

in their web projects. (Me neither, btw.)

Saving one from having to declare the used type on every instance of <script> and <style>, it does not seem to have any drawbacks. Yet, in fact, I have never seen one of them in the wild. Are there any considerations one has to take when relying on these <meta> tags?

share|improve this question
2  
Probably because they're very unheard of. Most people are just used to typing <script type="text/javascript"> and <style type="text/css"> – BoltClock Jun 12 '11 at 4:15
1  
There are web-developers and web-copy-pasters. A little like BoltClock mentioned, most people just don't know about web development but still make cool looking webpages. – Milche Patern Jul 11 '13 at 18:40
up vote 22 down vote accepted

According to W3C, http-equiv values "content-style-type" & "content-script-type" attributes are unknown for HTML5 meta markup! Moreover, W3C validator throws the following error when an HTML5 page has such markups:

Line X, Column Y: Bad value Content-Script-Type for attribute http-equiv on element meta.

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

So essentially we are supposed to avoid them.

share|improve this answer
    
Yes, it gags on that because these have been removed in HTML5. Also worth of notice: in HTML4.01, document with event handlers and without a Content-Script-Type meta tag are incorrect (w3.org/TR/html4/interact/scripts.html#h-18.2.2). In HTML5, Content-Script-Type is either ignored or incorrect (not sure of either), and event handlers must be written using ECMA-262. – Alek Jan 8 at 12:16

All web browsers that I've heard of will default to assuming type="text/javascript" on all <script> tags, and type="text/css" on <style> tags. (The only meaningful alternative I've heard of is VBScript for <script> tags in MSIE, which is heavily deprecated. There's no alternative to CSS.) In recognition of this, the HTML5 spec defines both attributes as being newly optional.

As such, there's no point in the Content-Script-Type and Content-Style-Type meta tags -- as far as I'm aware, they're ignored by most, if not all, browsers.

share|improve this answer

It's a shame that these settings have become deprecated with HTML5. Because, as nobody else seems to be mentioning, you can put default character set settings in there as well! Thus:

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

share|improve this answer
<meta http-equiv="Content-Style-Type" content="text/css; charset=UTF-8;">

The CSS meta is important for inline styles where we can't declare the type, so:

<span style="background:pink">
share|improve this answer

Speaking as a developer who just learned about these tags from your question, I'd say that it's the curse of the legacy browsers (I'm looking at you, IE6). Because when I learn about new tags, I usually continue not using them. I always assume browsers might not support any feature that I've never heard of, until I prove otherwise (which takes time), and since you have to program to the least common denominator (even if you "progressively enhance" later), that means, in this case, using the safer, more verbose method.

Having said that, I may actually give these a try. There's little risk, unless you're using content types other than text/javascript and text/css, since those have been the assumed defaults, like, forever. Indeed, as @duskwuff points out, there's probably no point in using either.

share|improve this answer

They are depreciated. Now, people use <script type='text/javascript> and <style type='text/css'>.

share|improve this answer
1  
If they are deprecated, you should give a reference to a W3C document (for example) saying so, or a reason why it is fair to call them 'deprecated'. – Andreas Rejbrand Jul 19 '13 at 22:31
<script type="text/javascript">

is depricated, so use

<script type="application/javascript">

instead like mentioned here in april 2006. Start here to find the last content.

share|improve this answer
2  
If I'm not entirely wrong, nobody of the W3C or WHATWG cares about RFC 4329 (but you may prove me wrong!). Furthermore, to use script type="application/javascript" is wrong. You are mixing up unrelated standards. – Kay Jul 24 '13 at 4:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.