Javascript Syntax


Javascript is placed between two <script> and </script> while writing HTML documents.

  • Syntax:

    <script>
    .
    .
    .
    </script>
Javascript can be placed anywhere in HTML but it is recommended to keep it in between <head> and </head> tags.

Javascript can also be written in other file but one needs to mention connectors.

When one mentions <script> tags browser understands that given script is javascript but it is recommended to mention these.

    Syntax:

  • <script language="javascript" type="text/javascript">
    .
    .JAVASCRIPT
    </script>

Case sensivity in javascript

Javascript is a case sensitive language unlike HTML if you mention any thing in capital letters or small letters entire script becomes completely different thing.

Comments in javascript

Comments in javascript can be placed after //.Any thing written after this is neglected by browser and it never appears in output.

Example of javascript

<!DOCTYPE html>
<html>
<head>
<title>
JAVASCRIPT EXAMPLE
</title>
</head>
<body>
<script>
document.write("HELLO JAVASCRIPT")
</script>
</body>
</html>

Output: