HTML JavaScript


JavaScript makes HTML pages more dynamic and interactive.


Examples

Online Examples

Insert a script
How to insert a script into an HTML document.

Use <noscript> tag
How to deal with browsers that do not support scripts or disable scripts.


HTML <script> tag

<script> tag is used to define client-side scripts, such as JavaScript.

<script> element can contain script statements or point to external script files via the src attribute.

JavaScript is most commonly used for image operations, form validation, and content dynamic updates.

The following script will output "Hello World!" to the browser:

Example

<script> document.write("Hello World!"); </script>

Try it »

RemarkTip:Learn more about JavaScript tutorials, please checkJavaScript tutorial!


HTML <noscript> tag

<noscript> tag provides alternative content when browsers do not support scripts or disable scripts.

The <noscript> element can contain all elements that can be found in the body of an HTML page.

Only when the browser does not support scripts or disables scripts will the <noscript> element display its content:

Example

<script> document.write("Hello World!") </script> <noscriptSorry, your browser does not supportJavaScript!</noscript>

Try it »


JavaScript experience (from the JavaScript tutorial on this site)

JavaScript example code:

JavaScript can be directly output in HTML:

document.write("<p>This is a paragraph.</p>");

Try it »

JavaScript event response:

<button type="button" onclick="myFunction()">Click me!</button>

Try it »

JavaScript handles HTML styles:

document.getElementById("demo").style.color="#ff0000";

Try it »


HTML script tag

Tag Description
<script> Defines the client-side script
<noscript> Defines the text to be output when browsers do not support scripts or disable scripts.
Other extensions