Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Take A QuizChallenge yourself and boost your learning! Start the quiz now to earn credits.
Take A QuizUnlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
Take A QuizWhen writing in HTML, the <script> tag is an inline element used to designate a client-side script on a web page. The <script> tag EITHER points to an external script file or contains scripting statements. It is useful for adding things like DYNAMIC content or form validation. The following sections contain information about this tag, including an example of it in use, and related attributes and browser compatibility.
Example of <script> code<script>document.write("Your browser supports JavaScript.")</script>document.write("Your browser supports JavaScript!")Sorry, your browser does not support JavaScript.
Example explanationIf you browser supports JavaScript, you see the message "Your browser supports JavaScript." If not, you see the message "Sorry, your browser does not support JavaScript."
AttributesWithin an HTML tag, an attribute DICTATES certain aspects of an HTML element. Attributes are made up of a name and value pair; all tags support standard attributes. The following table shows all of the current unique HTML attributes for the <script> tag, and a description of each.
NoteThe type attribute is optional in HTML5, but still required in HTML 4.
Attribute | Description |
---|---|
async | Designates that the script should be executed asynchronously (external scripts only). |
charset | Designates the character encoding used with an external script file. |
defer | Designates that the script is executed once the page has finished parsing (external scripts only). |
src | Designates the URL of an external script file. |
type | Designates the script's media type. |
A deprecated attribute is ONE that may function currently but is not supported in going forward. While the attribute may work with the current version of HTML, it will eventually be phased out. It is better to avoid using these attributes to help future-proof your website.
Attribute | Description |
---|---|
xml:space | Designates whether or not whitespace in code should be preserved. |
Edge | Internet Explorer | Firefox | Safari | Opera | Chrome |
---|---|---|---|---|---|
All versions | All versions | All versions | All version | All versions | All versions |
Turn Your Knowledge into Earnings.
Ever curious about what any word really means? Dictionary has got them all listed out for you to explore. Simply,Choose a subject/topic and get started on a self-paced learning journey in a world of word meanings and translations.
Write Your Comments or Explanations to Help Others