Does HTML5 require spaces between attributes with quoted values?

HTML usually does not allow spaces between attributes when attributes have values ​​and these values ​​are quoted.

Example ( Link / Source ):

There are no white spaces between attributes in HTML documents.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>no attribute space</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <p class="CLASS"title='TITLE'></p> </body> </html> 

See the third line:

  <p class="CLASS"title='TITLE'></p> ^^ 

Now, using an HTML snippet that changes doctype to HTML 5 ( <!DOCTYPE HTML> ), does an experimental W3C HTML 5 check to report an error:

Test Result: 1 Error

Error line 9, Column 22: There is no space between the attributes.

  <p class="CLASS"title='TITLE'></p> ^ 

So, I thought HTML 5 was backward compatible with the way browsers actually handle HTML, and AFAIK browsers do this well. At least I'm a little puzzled. I also have problems decoding (somewhat unnecessary) compiled HTML 5 specifications to be accurate at this point, because what I found (W3C again, see http://www.w3.org/TR/ html-markup / syntax.html # syntax-attributes ) without saying that this (may and should not) be a mistake.

+8
html
source share
3 answers

You are reading a broken, non-normative link. If you look at the definition of the start tag in the specification (which is normative), it says:

Then, the start tag can have several attributes, the syntax for which is described below. Attributes must be separated by one or more space characters .


So, I thought HTML 5 was backward compatible with the way browsers handle HTML in reality and AFAIK browsers do it well.

Compatibility with real-world markup is a design goal, but many things are outdated, and the space between attributes is something that almost never happens intentionally.

+9
source share

Section 4.3 β€œElements” of the document that you indicate in the question says:

Optionally, one or more attributes, each of which must be preceded by one or more space characters.

+1
source share

Use W3C An official HTML Validator that does not have spaces between attributes is checked as errors if you use HTML5 Doctype:

 <!DOCTYPE html> 

The output message is as follows:

Row 9, Column 23: There is no space between the attributes.

-2
source share

All Articles