You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When specified on HTML elements, the id attribute value must be unique amongst all the IDs in the element's tree and must contain at least one character. The value must not contain any ASCII whitespace.
I'd suggest trimming whitespace from the IDs. It may also be sensible to do that on the other attributes. Of course, the behaviour does depend on how closely you want to follow the input's mistakes. If the intention is to closely replicate the input (whether their original code was valid or not) then please close this bug.
PHP Version
PHP 8.4.6 (cli) (built: Apr 11 2025 02:19:14) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.4.6, Copyright (c) Zend Technologies
with Zend OPcache v8.4.6, Copyright (c), by Zend Technologies
Operating System
Pop!_OS 22.04 LTS
The text was updated successfully, but these errors were encountered:
The docs you cited describe how the developer should author HTML documents, not how it should be parsed.
The parser spec does not contain a rule to strip the whitespace and diverging from that would be dangerous.
Browsers also don't do this:
Description
The following code:
Resulted in this output:
But I expected this output instead:
As per https://html.spec.whatwg.org/multipage/dom.html#global-attributes:the-id-attribute-2
Further detail at https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/id#syntax
I'd suggest trimming whitespace from the IDs. It may also be sensible to do that on the other attributes. Of course, the behaviour does depend on how closely you want to follow the input's mistakes. If the intention is to closely replicate the input (whether their original code was valid or not) then please close this bug.
PHP Version
PHP 8.4.6 (cli) (built: Apr 11 2025 02:19:14) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.4.6, Copyright (c) Zend Technologies
with Zend OPcache v8.4.6, Copyright (c), by Zend Technologies
Operating System
Pop!_OS 22.04 LTS
The text was updated successfully, but these errors were encountered: