Web-Development-Tutorials Home
Web Development Tutorials
HTML Tutorials
CSS Tutorials
Javascript Tutorials
PHP Tutorials

Free Web Development
Tools
Free CSS Templates
Free Website Directories
Free Hit Counters
Free Music and
Online Radio Stations

Free SEO Tools
Free Page Rank Checker
Free Back Link Checker
Free Google Banned Checker
Free Keyword Density Checker
Free Link Popularity Checker
Free Search Engine Keyword Position Checker
Free Search Engines Lisitings Preview
Free Link Extractor
Free Source Code Viewer
Free Domain Tools
Free Domain Name Availability Tool
Free Domain Whois Lookup
Free Ping Test
Free Reverse/IP Lookup
Misc Free Web Development Resources
View Web Browser Details

Web-Development-Tutorials.com

Free Web Development Tutorials for Web Developers
from Beginners to Professionals

Writing and Embedding Javascript within an HTML Document

Javascript can be inserted within an HTML document by putting the javascript code within openning and closing <script> </script> tags. Javascript statements that are written within the <script> tags are executed when the web page loads in a browser.

<script> tags can be placed within the <head> and <body> tags and a web page can contain more than one set of <script> tags.

The following Javascript code example shows you how to insert Javascript within an HTML document.

To view the page the code produces, click Javascript Code Example 1

<html>
<body>

<script type="text/javascript">
document.write("Hello World! from Web-Development-Tutorials.com")
</script>

</body>
</html>

Text that is displayed to a web browser will be located in the corresponding location of the HTML document within the <script> tags.


Adding Text Formatting

The following Javascript code example shows you how to add text formatting.

To view the page the code produces, click Javascript Code Example 2

<html>
<body>

<script type="text/javascript">
document.write("<h1>Hello World! from Web-Development-Tutorials.com</h1>")
</script>

</body>
</html>


How to Add a Background Color

The following Javascript code example shows you how to add text formatting and a bgcolor. Notice that the "C" in bgColor is capitalized.

To view the page the code produces, click Javascript Code Example 3

<html>
<body>

<script type="text/javascript">
document.bgColor = "grey" ;
document.write("<h1>Hello World! from Web-Development-Tutorials.com</h1>")
</script>

</body>
</html>