JavaScript > Placing JavaScript code

Code in html page in JavaScript

How to write JavaScript code in the html page?

The JavaScript code can be kept into html page inside <script> tag.

<!DOCTYPE html>
<html xmlns="">

    <p style="color:red">Hello world using HTML!</p>

        document.write("<b>Hello world using JavaScript!</b>");


Above code snippet, shall write the text in inverted comma on the page in bold style. 

Note that <script> block ideally should be written inside the <head></head> block however it can be kept anywhere inside the <body></body> tag also.

 Views: 5480 | Post Order: 5

Write for us

Hosting Recommendations