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

I already searched for a while, and I could not find links to whether it is safe / possible to remove the space here:

<meta http-equiv="Content-Type" content="text/html; this is the space charset=UTF-8" />

I also tried to compress the script in "Aggressive minimization", but they don't seem to remove it.

I see that they have removed the space for this example website . But I can no longer rely on such sites.

+4
source share
4 answers

The Content-Type header specification does not actually allow spaces around semicolons to separate parameters:

http://www.ietf.org/rfc/rfc2045.txt

  5.1.  Syntax of the Content-Type Header Field

    In the Augmented BNF notation of RFC 822, a Content-Type header field
    value is defined as follows:

      content: = "Content-Type" ":" type "/" subtype
                 * (";" parameter)

      ...

      parameter: = attribute "=" value

But it seems that clients / servers reliably handle the spaces that are added, possibly so that the headers are more human readable. You can safely lower the space.

+4
source

The media type specification, RFC 2045, does not require a space. It also does not prohibit space; this is more implicit since RFC 2045 refers to the enhanced BNF, as defined in RFC 822, which is explained in section 3.4.2. WHITE SPACE:

"Note: in structured field bodies, several linear spaces of ASCII characters (namely HTABs and SPACE) are treated as single spaces and can freely surround any character. In all header fields, the only place where at least one LWSP-char is REQUIRED be at the beginning of continuation lines in a folded field. "

In accordance with HTML5 drafts, the specific type of meta tags discussed can be written in the following more compact form, on the basis that user agents have long recognized it:

 <meta charset=UTF-8> 

If XHTML serialization is required, use

 <meta charset="UTF-8" /> 

This is more readable and safer (fewer cases of manual input errors).

+9
source

no harm in the sense that there is a semicolon ";" after text/html ...

+1
source

It seems like there was once an error in Exchange Web Server that required space, but the browser as a whole didn't care.

0
source

Source: https://habr.com/ru/post/1393575/


All Articles