HTML5 <meta charset="utf-8">#11479
Conversation
Is there some docs or an RFC or something along those lines you could link me to for this?
If there is clear, specific advice from an appropriately authoritative source, then we should follow that advice. In the absence of specific advice I'd be inclined to leave them how they are. |
|
I think the links in #3031 should describe why to use Essentially, it's the way HTML5 is written those days. The longer version is a legacy from HTML4. The shorter version is recommended by the HTML5 specification, is easier to read and more concise. It's equally well supported and achieves the same result as the longer version. As linked in #3031 W3C recommends not using trailing slashes on void elements. This is because it has no effect and interacts badly with unquoted attribute values.
The consensus across these sources is that trailing slashes on void elements:
However, it's worth noting that DOMDocument versions before PHP 8.4 may not support void elements without trailing slashes, as linked above. I have no clear view on it, but sooner or later Silverstripe should follow the latest recommendations. |
|
PHP DOMDocument shows its age or am I missing something? Since I wasn't able to make the tests below pass with |
Description
<meta charset="utf-8">should be used exclusively, instead of<meta http-equiv="Content-Type" content="text/html; charset=utf-8">or both as it is not needed for HTML5. W3C Validator also flags self-closing tags as an issue. While Symfony has reverted such a change, still it would make sense to remove those esp. in light of PHP 8.4 DOM HTML5 parsing. What is your opinion on handling self-closing tags?Manual testing steps
A PR will follow in the CMS for ensuring HTML5 compliance. Additionally, simple theme should be updated to address this issue. Ultimately, only a single
<meta charset="utf-8">should be used.Issues
#7438
Pull request checklist