HTML <script> tag
Try it yourself!
Definition and Usage
The script element either contains scripting statements or it points to an
external script file through the src attribute.
The required type attribute specifies the MIME type of the script.
dynamic changes of content.
The <script> tag is supported in all major browsers.
Differences Between HTML and XHTML
HTML 4 and XHTML deal different with the content inside scripts:
- In HTML 4, the content type is declared as CDATA, which means that
entities will not be parsed.
- In XHTML, the content type is declared as (#PCDATA), which means that
entities will be parsed.
This means that in XHTML, all special characters should be encoded or all
content should be wrapped inside a CDATA section.
To ensure that a script parses correctly in an XHTML document, use the
Tips and Notes
Tip: Also look at the noscript element
for users that have disabled scripts in their browser or have a browser that
doesn’t support client-side scripting.
DTD indicates in which DTD the attribute is
allowed. S=Strict, T=Transitional, and F=Frameset.
||Specifies the MIME type of a script
||Specifies the character encoding used in an external script
||Specifies that the execution of a script should be deferred
(delayed) until after the page has been loaded
||Specifies the URL of an external script file
||Specifies whether whitespace in code should be preserved
The Altova MissionKit is a suite of intelligent XML tools, including:
XMLSpy® – industry-leading XML editor
- Support for all XML-based technologies
- Graphical editing views, powerful debuggers, code generation, & more
MapForce® – graphical data mapping tool
- Drag-and-drop data conversion with code generation
- Support for XML, DBs, EDI, Excel® 2007, text, Web services
StyleVision® – visual stylesheet designer
- Drag-and-drop stylesheet design for XML & databases
- Output to HTML, PDF, RTF, Word 2007, & more
Try before you buy with a free fully functional 30-day trial
Get Your Diploma!
W3Schools' Online Certification Program is the perfect solution for busy
professionals who need to balance work, family, and career building.
The HTML Certificate is for developers who want to document their knowledge of HTML, XHTML, and CSS.
The XML Certificate is for developers who want to document their knowledge of XML, XML DOM and XSLT.
The ASP Certificate is for developers who want to document their knowledge of ASP, SQL, and ADO.
The PHP Certificate is for developers who want to document their knowledge of PHP and SQL (MySQL).