Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it safe to remove the space between 'content' and 'charset'?

I already searched for a while, and I failed to find any references on whether it is safe/possible to remove the space here:

<meta http-equiv="Content-Type" content="text/html;this spacecharset=UTF-8" />

I also tried compressing the script on 'Aggressive Minimization', but they don't seem to remove it.

I see that they removed the space on this website example. But I can't rely on that kind of websites any more.

like image 432
ajax333221 Avatar asked Jan 29 '12 04:01

ajax333221


People also ask

Is meta charset necessary?

It is not necessary to include <meta charset="blah"> . As the specification says, the character set may also be specified by the server using the HTTP Content-Type header or by including a Unicode BOM at the beginning of the downloaded file.

What is charset in HTML Why will you use it?

The charset attribute specifies the character encoding for the HTML document. The HTML5 specification encourages web developers to use the UTF-8 character set, which covers almost all of the characters and symbols in the world!

What is the purpose of meta charset UTF-8?

Unfortunately, ASCII only encodes English characters, so if you used other languages whose alphabet does not consist of English characters, the text wouldn't be properly displayed on your screen. Thus, UTF-8 was created to address ASCII's shortcomings and can translate almost every language in the world.

What is a charset UTF-8?

charset = character set utf-8 is character encoding capable of encoding all characters on the web. It replaced ascii as the default character encoding. Because it is the default all modern browsers will use utf-8 without being explicitly told to do so. It remains in meta data as a common good practice.


2 Answers

The specification of media types, RFC 2045, does not require a space. Neither does it prohibit a space; this is more implicit, since RFC 2045 refers to the extended BNF as defined in RFC 822, which clarifies this in clause 3.4.2. WHITE SPACE:

“Note: In structured field bodies, multiple linear space ASCII characters (namely HTABs and SPACEs) are treated as single spaces and may freely surround any symbol. In all header fields, the only place in which at least one LWSP-char is REQUIRED is at the beginning of continuation lines in a folded field.”

According to HTML5 drafts, the specific kind of meta tags under discussion can be written in the following more compact form, on the grounds that user agents have long recognized it:

<meta charset=UTF-8>

If XHTML serialization is needed, use

<meta charset="UTF-8" />

This is more readable and safer (fewer possibilities of mistyping when you type it by hand).

like image 95
Jukka K. Korpela Avatar answered Oct 12 '22 12:10

Jukka K. Korpela


there is no harm in that as long as there is the semicolon ";" after text/html...

like image 42
Desolator Avatar answered Oct 12 '22 10:10

Desolator