How to fix: Required attribute "type" not specified

Most Likely Cause and Fix

Your markup contains a <style> or <script> element that lacks the required type attribute:

<script></script>
<style></style>

Add a suitable type attribute to each <style /> or <script /> element where missing:

<script type="text/javascript"></script>
<style type="text/css"></style>

Or switch to HTML5 where the type attribute on these elements is optional.

What This Error Means

There is a defined set of attributes for each HTML element. Some are required for your markup to be considered valid.

You have omitted the required type attribute on an element that requires it.

How To Fix It

The specific error message you encountered will refer to a line and column number. This will guide you to the exact point in your markup to which the error relates.

For style and script elements

You've most likely forgotten to add a type attribute to a <style> or <script> element:

<script></script>
<style></style>

Check the document type declaration used in your markup. Fix this if not correct.

Add a suitable type attribute to each <style /> or <script /> element where missing:

<script type="text/javascript"></script>
<style type="text/css"></style>

Or switch to HTML5 where the type attribute on these elements is optional.

In general

Find the relevant element and add the missing type attribute.

Discuss, Comment and Improve

Did this help you? Can this page be improved? Let us know!

comments powered by Disqus