QuizCure
Find Available Solution Here!

DOCTYPE

Deepak Apr 24, 2024

DOCTYPE (Document type) is used to tell the browser about the version of HTML. Doctype must define at the beginning of the document.

Doctype is to be define as for HTML 5.

Definition
<!doctype html>
<html lang="en">
    <head>
        <title> Page Title</title>
    </head>
    <body>
    </body>
</html>

How to fix Uncaught SyntaxError: Unexpected token < ?

The Syntax error Uncaught SyntaxError: Unexpected token < is caused by following reasons :

  • File using in script tag return 404, mean browser trying to fetch javascript file which does not exist
  • Script tag supposed to have existing js file reference but provided another file
  • Also it can caused during ajax call expecting to receive response as defined in ajax url (ex: json) but return other format (ex. nomn json if requested for json)
Here is the example for more understanding

Example 1 : Expecting src url as javascript file but given html file path
<!doctype html>
<html lang="en">
    <head>
        <!-- Expecting src url as javascript file but given html file path -->
        <script src="index.html" ></script>
        <title> Page Title</title>
    </head>
    <body>
    </body>
</html>

Why exclamation mark is used in before doctype html?

To understand WHY let's first understand

what is markup declaration

According to markupdeclaration.org

Declarative markup is the practice of identifying what information in a document is, typically separate from how it should be processed or presented.
Therefore to declare about document it is used exclamation mark. Example 1 : To define any comment it define like <!-- comment --> Example 2: To define any Document type it used exclamation mark before doctype like <!doctype html>

Was this post helpful?

Send Feedback

Connect With QuizCure


Follow Us and Stay tuned with upcoming blog posts and updates.

Contributed By

Deepak

Deepak

QC STAFF
51 Posts
  • PHP
  • JAVA
  • PYTHON
  • MYSQL
  • SEO

You May Like to Read

Scroll up