Javascript Tutorials

How to place javascript in the body of a web page

The code below shows how to place javascript in the body of a web page.

Javascript that is place within the openning and closing <body> tags are executed when the web page loads and generates as part of the content of the web page.

<!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>
<script type="text/javascript">

</script>

</head>
<body>
<script type="text/javascript">
document.write("Hey I know javascript!");
</script>
</body>
</html>

The code above creates the javascript code below:

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