Javascript Tutorials

How to add comments to javascript

The code below shows how to add comments to javascript.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<title>Web Development Tutorials.com</title>

<style type="text/css">


</style>

</head>
<body>
<script type="text/javascript">
document.write("Hey I know javascript!");
// this text will not be displayed on the web browser
/* this text will also not be displayed
on the web browser*/
</script>
</body>
</html>

Single-line comments are designated by 2 forward slashes (//). Any text on a line following the 2 forward slashes will not be displayed in a web browser.

Multiple-line comments start with a forward slash followed by an asterisk (/*) and end with an asterisk followed by a forward slash (*/). Any text that is within /* and */ will not be displayed on a web browser.

The code above creates the text below.

Use the text editor below to practice what you have learned.