HTML5 does not actually implement the concept of "self-closing tags". It is a relic from XHTML. From http://www.w3.org/TR/html5/syntax.html#syntax-start-tag:
Then, if the element is one of the void elements, or if the element is a foreign element, then there may be a single "/" (U+002F) character. This character has no effect on void elements, but on foreign elements it marks the start tag as self-closing.
It has "no effect on void elements", meaning it is ignored when being parsed.
Remove all unnecessary
/ characters from void elements in core-provided templates, documentation, sources and output:
area, base, br, col, embed, hr, img, input, keygen, link, meta, param, source, track, wbr
This DOES NOT (and should not) include user generated content. For example, if a content editor inserts a
<br /> tag into a body of a node, it should be preserved by filter as is.
- Document self-closing tags usage in coding standards both for HTML and JS.
Documentation should clearly describe the difference between void tags and foreign elements, as well as the usage of
<div />syntax in JS.
- Can templates in
stabletheme be modified in minor release?
- Remove self-closing void tags from output of
filtermodule without breaking its current behavior.
Filters should not forcibly remove the closing slash if it is added by user, but they should not forcibly add it in either.
- Reconfigure editor to not generate these tags in content and update tests in
- Test the behavior of
Drupal\Core\Mail\MailFormatHelper::htmlToTextto make sure that it can transform both cases.
- Update XSS filtering tests to verify that they cover both normal and self-closing void tags (i.e.
- Decide if it is necessary to remove self-closing tags from test fixtures.
A quote from @sun's comment #48 on migrations:
The D6 source configuration may contain self-closing tags, so migration tests should not be changed.
That said, perhaps we want to process such config in a way to automatically adjust self-closing tags during the migration, but that should be discussed in a separate/dedicated issue.
User interface changes
bartik theme templates and default module templates.
Original report by @tim.plunkett
There are 11 uses of
<br> in core, and 87 of
<br />. I've never once used the latter, and both are valid HTML: http://dev.w3.org/html5/spec-author-view/syntax.html#syntax-start-tag
I propose core switch everything to
Either way, we should pick one for core, and clarify in the coding standards that one is preferred but both are allowed.