Tutorials

KodeKite Tools

HTML
Flexbox
SVG
Canvas
HTML Tutorial

More


HTML Script Element
Script Element

HTML script element defines javascript in HTML document. It is inserted in head or body section of HTML page and used as internal or external javascript.

Syntax

<script>JavaScript code</script>


You can use script element any where within HTML document.


Example

Heading 1


Script is a pair tag and output of script element is javascript code like you can see in above example.


Practice Task

Open notepad or any other text editor, follow the following points.


  • Write one paragraph element
  • Assign id name p to paragraph
  • Apply JavaScript using script element and get id by its name
  • JavaScript output should be text like Paragraph has changed
  • Put script element in body section of HTML page not in head section

save file with name task.html or task.htm and then open it using any browser and see results.


Solution

Paragraph


Don't forget script is non empty element which means it always comes in pair.