Definition and Usage.
The <script> tag is used to define a client-side script, such as a JavaScript.
The script element either contains scripting statements or it points to an external script file through the src attribute.
The required type attribute specifies the MIME type of the script.
Common uses for JavaScript are image manipulation, form validation, and dynamic changes of content.
Example.
<html>
<body>
<script type="text/javascript">
document.write("Hello World!")
</script>
</body>
</html>
Differences Between HTML and XHTML.
HTML 4 and XHTML deal different with the content inside scripts:
This means that in XHTML, all special characters should be encoded or all content should be wrapped inside a CDATA section.
To ensure that a script parses correctly in an XHTML document, use the following syntax:
<script type="text/javascript"><![CDATA[
document.write("Hello World!")
//]]></script>>
No response to “Use of Java Script.”
Post a Comment