Showing posts with label html script tag. Show all posts
Showing posts with label html script tag. Show all posts

Saturday, August 20, 2022

html script tag attributes

 SCRIPT Element 


SCRIPT Element img


The SCRIPT element is used to declare a script, such as JavaScript, within an HTML document e embedded external javascript file through the src attribute. You can use the SCRIPT element for validating Web forms and manipulating the content and images present on these forms. 

<script>

document.getElementById("demo").innerHTML = "Hello JavaScript!";

</script>

 The SCRIPT element is used inside the HEAD element, which uses the type attribute. The type


1 Introduction to scripts

A client-side script is a program that may accompany an HTML document or be embedded directly in it. The program executes on the client's machine when the document loads, or at some other time such as when a link is activated. HTML's support for scripts is independent of the scripting language.

Scripts offer authors a means to extend HTML documents in highly active and interactive ways. For example Scripts may be evaluated as a document loads to modify the contents of the document dynamically.

Scripts may accompany a form to process input as it is entered. Designers may dynamically fill out parts of a form based on the values of other fields. They may also ensure that input data conforms to predetermined ranges of values, that fields are mutually consistent, etc. Scripts may be triggered by events that affect the document, such as loading, unloading, element focus, mouse movement, etc.

Attribute 

1. Async 

Value :- true, false

Description :-

For classic scripts, if the async attribute is present, then the classic script will be fetched in parallel to parsing and evaluated as soon as it is available. For module scripts, if the async attribute is present then the scripts and all their dependencies will be executed in the defer queue, therefore they will get fetched in parallel to parsing and evaluated as soon as they are available.

This attribute allows the elimination of parser-blocking JavaScript where the browser would have to load and evaluate scripts before continuing to parse. defer has a similar effect in this case. This is a boolean attribute: the presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value.


2.  NOSCRIPT element


The NOSCRIPT element is used to display the alternate content on the Web browser that either does not support JavaScript or has JavaScript disabled. If the JavaScript is enabled or supported by the Web browser, the NOSCRIPT element is not considered. The following code snippet shows an example of the NOSCRIPT element.

The noscript element represents nothing if scripting is enabled, and represents its children if scripting is disabled. It is used to present different markup to user agents that support scripting and those that don't support scripting, by affecting how the document is parsed.

<script type="text/javascript">

document.write("Good Morning.")

</script> 

<NOSCRIPT>Javascript is disabled or not supported on your browser.</NOSCRIPT>

The NOSCRIPT element can only be applied on the elements that are inside the BODY element. If you do not want to apply script on any session of the BODY element, you can define it in the NOSCRIPT element. This element cannot contain any nested elements.


3 The STYLE Element:

The STYLE element is used to declare the style sheets within the HTML document. This element specifies how the HTML elements are rendered in a browser. The STYLE element has three attributes: type, media, and scoped. Generally, the STYLE element is placed inside the HEAD element but if you use the scoped attribute, then you can place the STYLE element in the BODY element of the document. The following code snippet shows the use of the STYLE element in a document:

<HEAD>

<STYLE type="text/css">

body (background-color: powderblue;}

hi (color: red;)

p [color: blue;)

</STYLE></HEAD>


In the preceding code snippet, the STYLE element is used within the HEAD element


Script element extra information

Related Post


horizontal navigation bar

type css selectors

element tag