Example
<p>script element is used to add javascript in a page. For example, we make a function of cube in javascript.</p>
<script>
var x=5;
function product(x){
document.write(x*x*x);
}
product(5);
</script>
Try </>
Web development courses to make an interactive and responsive website.
HTML <script> tag adds the script in the html document. Script can be added directly in between the elements (inline) or imported from an external source using src attribute.
<p>script element is used to add javascript in a page. For example, we make a function of cube in javascript.</p>
<script>
var x=5;
function product(x){
document.write(x*x*x);
}
product(5);
</script>
Try </>
It makes the content dynamic.
Tip: The script should be placed at the end of a page.
All the global attributes are applicable on the script element.
Both opening and closing tags are necessary for the script element.
Attributes | Description |
---|---|
src | Address of the file to be imported. |
| |
type | Specifies the type of language of the script. |
| |
crossorigin | describes about the crossorigin requests. |
| |
charset | describes about the crossorigin requests. |
|
Was this article helpful?
Email:
Message:
Get the newsletter