script element can include scripting in your pages, either defined inline in the document or referenced to an external file.
You use one script element for each script.
The script element has local attributes:
type attribute is optional in HTML5. The
defer attributes have been added in HTML5.
<!DOCTYPE HTML> <html> <head> <script> document.write("This is from the script"); </script> </head> <body> <a href="http://www.studentsempire.com">click </body> </html>
By default, scripts are executed as soon as they are encountered in the page. You usually use the script element inside the head element, but you may use it anywhere in an HTML document.
You can separate scripts into separate files and load them using the script element.
The file contains a single statement. Then we can use the src attribute in the script element to reference this file.
A script element must be empty if it uses the src attribute. You can't use the same script element to define an inline script and an external script.
An end tag for the script element is needed, even though the element has no content. If you use a self-closing tag when referencing an external script, the browsers will ignore the element and not load the file.
You can control the execution of a script by using the async and defer attributes.
The defer attribute tells the browser not to execute the script until the page has been loaded and parsed.