Last Updated : 03 Oct, 2024
The HTML <link> element's charset attribute specifies the character encoding for the linked resource, typically for external stylesheets or scripts. It was primarily used with links to external files, but it's now obsolete and rarely needed as encoding is usually specified directly in the file itself or through HTTP headers.
Syntax<link charset="character_set">Attribute Values
It contains a single value character_set which specifies the character encoding for the HTML document. The values of character_set are:
Example: In this example the charset attribute in the HTML <link> element specifies the character encoding (e.g., ISO-8859-1) for the linked resource.
html
<!DOCTYPE html>
<html>
<head>
<title>
HTML link charset Attribute
</title>
</head>
<body style="text-align:center">
<H1>GeeksforGeeks</H1>
<h2>HTML link charset Attribute</h2>
<link href="gfg.html" charset="ISO-8859-1">
</body>
</html>
Output:
Supported BrowsersThe browser supported by HTML <link> charset attribute are listed below:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4