HTML: Is the "type" attribute REALLY necessary?

Chris Gates

New member
I've been programming and developing web pages for quite some time. However, I never fully understood the purpose of needing to specify a content-type for the HTML document (via the meta tag), in addition to the "type" attribute on tags like <link> and <script>.

Examples:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="script.js"></script>

I've always been taught that it is the server that determines the MIME type and not the element tag. If that is true, then when (or, perhaps more importantly, why?) would it ever be necessary to include this information in the HTML document?

I add the the type attribute to my elements to get my HTML documents to validate, but I'm curious to see what other web developers think about the type attribute and see their take on why the W3C feels it is necessary to bloat HTML documents with crap that doesn't appear to be meaningful in any way.
Thank you Cubbi and P L for your valuable insight! It hadn't even occurred to me that the external file would not be an HTTP URL... but that certainly makes more sense now.

As for embedding JavaScript in the HTML document, I say bleh! I guess I'm so used to separating the two that I had forgotten that people still do that sort of thing. =)

Thanks again to both of you for your wonderful answers!
 
Back
Top