3 ms·
Valid HTML allow optional end tags? For example?
by The_rationalist 6y ago
Valid HTML allow optional end tags? For example?
- lifthrasiir 6y ago`<script>` is an usual example that you can't self-close and absolutely need to be followed by `</script>` in HTML5. In general though self-closing tag has no effect in HTML5 anyway, `<script>` is just an example where the usual heuristic specified by HTML5 doesn't help you at all (since it switches the lexer state).
- deleted 6y ago[deleted]
- chrismorgan 6y agohttps://html.spec.whatwg.org/multipage/syntax.html#optional-tags https://html.spec.whatwg.org/multipage/syntax.html#optional-... describes which elements have optional start and end tags. This document is valid: <!doctype html> <title>Hello,</title> <p>World! <ul> <li>A <li>B </ul> <table> <tr> <th>C <td>D <td>E <tfoot> <tr> <th>F <td>G <td>H </table> And is precisely equivalent to this document in the canonical serialisation: <!DOCTYPE html><html><head><title>Hello,</title> </head><body><p>World! </p><ul> <li>A </li><li>B </li></ul> <table> <tbody><tr> <th>C </th><td>D </td><td>E </td></tr></tbody><tfoot> <tr> <th>F </th><td>G </th><td>H </td></tr></tfoot></table></body></html>