markup.rs icon indicating copy to clipboard operation
markup.rs copied to clipboard

Correctly render void elements

Open Kijewski opened this issue 5 months ago • 2 comments

A void element is an HTML element that cannot have any children. In XML you'd use such an element like <br />.

HTML5 is very lenient, in that you don't have to write the trailing slash. A correctly implemented HTML parser knows which elements are void elements, and it closes the element automagically for you. The parser even "corrects" an input like a<br></br>b to a<br /><br />b for you, which might not be desirable.

If you want to render SVG, XHTML, or other more strict XML applications, you have to close void elements correctly: <br />, NOT <br> or <br></br>.

This PR adds the missing slash to generated void elements, so markup can be used to render e.g. SVG files.

Kijewski avatar Feb 04 '24 02:02 Kijewski