Dofactory.com
Dofactory.com

HTML <script> charset Attribute

The charset attribute on a <script> tag specifies what character set is used in the script.

If not specified, the character set will be set to UTF-8.

Example

#

A charset attribute on a <script> element.

<script src="/tutorial/script-async.js" charset="utf-8">
</script>

Using charset

The charset attribute informs the browser the character set to use.

This attribute can be specified in each page.

The default character set is UTF-8 for HTML5 documents.


Syntax

<script charset="charset">

Browser support

Here is when charset support started for each browser:

Chrome
8.0 Dec 2010
Firefox
3.6 Jan 2010
IE/Edge
10.0 Sep 2012
Opera
15.0 May 2013
Safari
5.1 Oct 2011

You may also like

 Back to <script>

Author: Jack Poorte
Published: Jun 20 2021
Last Reviewed: Sep 30 2023


What's your favorite/least favorite part of Dofactory?


Guides