HTML Script


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 does not support scripting or disable the browser script.


HTML <script> Tag

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

The <script> element can either contain script statements or point to an external script file through the src attribute.

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

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

Example

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

 Try It! 

RemarkTip: To learn more about Javascript tutorial, please check JavaScript tutorial !


HTML <noscript> Tag

The <noscript> tag provides alternative content when scripts cannot be used, such as when scripts are disabled in the browser, or when the browser does not support client-side scripting.

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

The content in the <noscript> element will only be displayed when the browser does not support scripting or when scripting is disabled:

Example

<script>
  document.write("Hello World!")
</script>
<noscript>
  Sorry, your browser does not support JavaScript !
</noscript>

Try It! 


JavaScript Experiences (JavaScript Tutorial)

JavaScript example code:

JavaScript can be output directly 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 style:

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

Try It! 


HTML Script Tags

LabelDescription
<script>Client script defined
<noscript>Defines text that does not support script browser output