
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How do we display a script in HTML?
To add a script, use the <script> tag. The HTML <script> tag is used for declaring a script (such as JavaScript) within your HTML document.
The script tag supports the following additional attributes −
Attribute | Value | Description |
---|---|---|
async ![]() | sync | Specifies that the script is executed asynchronously |
Charset | charset | Defines the character encoding that the script uses. |
defer | defer | Declares that the script will not generate any content. Therefore, the browser/user agent can continue parsing and rendering the rest of the page. |
src | URL | Specifies a URI/URL of an external script. |
type | text/JavaScript application/ecmascript application/JavaScript text/vbscript | Specifies the scripting language as a content-type (MIME type). |
xml:space | preserve | Deprecated − Whether the whitespace in code should be preserved |
Example
You can try to run the following code to display a script in HTML −
<!DOCTYPE html> <html> <head> <title>HTML script Tag</title> </head> <body> <script> document.write("You're visiting tutorialspoint!") </script> </body> </html>
- Related Questions & Answers
- How do we display a table cell in HTML
- How do we display a text area in HTML?
- How do we display inserted text in HTML?
- How do we use Python in script mode?
- How do we include the direction of text display in HTML?
- How do we display the visible width of a text area in HTML?
- How do we add a comment in HTML code?
- How do we include a table caption in HTML?
- How do we add a definition term in HTML?
- How do we add a noframe section in HTML?
- How do we add a noscript section in HTML?
- How do we define a dialog box in HTML?
- How do we add a menu list in HTML?
- How do we add a table row in HTML?
- How do we create a sub window in HTML?
Advertisements