The <script> Tag :
The script tag has two purposes:
1. It identifies a block of script in the page.
2. It loads a script file.
What it does depends on the presence of src attribute.
The src attribute is optional. If it is present, then its value is a url which identifies a .js file. The loading and processing of the page pauses while the browser fetches, compiles, and executes the file. The content between the <script src=”url”> and the </script> should be blank.
If the src attribute is not present, then the content text between the <script> and the </script> is compiled and executed. In older versions of HTML it was necessary to specify a value for “type”. The scripting language is specified by the “type” attribute.
By default script tag is for client side if we want it to run on server side we have to add attribute which tells it runs on server side.
The document.write method provides a way of incorporating strings into the HTML content of the page.This simply prints the specified text to the page.
Changing HTML Content:
x=document.getElementById(“demo”); // Find the element
<button type=”button” onclick=”myFunction()”>Click Me!</button>
In this example we have assigned id to paragraph element which is demo. In the script tag we can also define funtions by using function keyword which is followed by the name of funtion myFunction in this case. The getElementById funtion returns html element having demo as id so in this case it returns paragraph element. The innerHTML funtion is used to change content of paragraph element.
Button tag <button> is used for buttons. Its onclick event is assigned funtion myFunction so whenever the button is clicked it calls the funtion.
The rel attribute is used to provide information about the relationship between the document that’s being linked to (as defined in the href attribute) and the referencing document.One of the most common uses of the rel attribute, in the context of the a element, is to specify a value of “nofollow”. This is to indicate to search engines that the linked document should not be indexed by the search engine, and that any reputation/value associated with the linking site is not passed on such that it benefits the linked page in search results.
The href attribute defines the document to which the link leads. This may be a web page in the same directory, a page somewhere else on the same server, a location within the current page, or a web page—or any another kind of document—stored on another server.