Support HTML5 void elements
See original GitHub issueIt would be great to be able to write standard HTML5 without needing to close tags like in JSX, which is just another small thing to learn for developers.
E.g: an image tag normally works but doesn’t in HTM: <img src="hi.png>
.
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (1 by maintainers)
Top Results From Across the Web
Void element - MDN Web Docs Glossary - Mozilla
A void element is an element in HTML that cannot have any child nodes (i.e., nested elements or text nodes). Void elements only...
Read more >Describe the void elements in HTML - GeeksforGeeks
There is a special group of elements that only have start tags and does not contain any content within it, these elements are...
Read more >Self-closing tags (void elements) in HTML5 - Stack Overflow
2.1 Start tags of the HTML5 spec says that void elements may have a single / character. I think this is so it's...
Read more >HTML Void Elements - RIP Tutorial
A void element cannot have any content but may have attributes. Void elements are self-closing, so they must not have a closing tag....
Read more >Void Elements in HTML5 - YouTube
Elements in HTML are not required to have content, but some elements cannot have content. These are called void elements.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
FWIW one of the reasons I don’t think we’re likely to consider this is because there are a lot of other HTML features that are unsupported in HTM. Adding a feature like void elements is net negative for performance, but it increases the likelihood of folks thinking HTM is an HTML parser. This assumption breaks down pretty quickly - attribute names are case-sensitive, whitespace is trimmed, etc.
HTM is also most often used with Virtual DOM libraries, which further diverge from HTML since they tend to adopt HTML’s property semantics for “props” rather than the string-only semantics of HTML attributes. We’ve actually had cases in Preact where folks using HTM have run into issues using namespaced attributes. VDOM doesn’t have those, and they’re only “supported” in HTM because it’s faster and smaller to pass-through namespaces than it would be to prevent their usage.
That all said, I do think it would be interesting for someone to resurrect the
htm@1
codebase and repurpose it as a standalone HTML-to-VDOM library. It would be the fastest implementation, support 100% of HTML (since it uses DOMParser), and weigh in at around 300b. A library for that purpose wouldn’t need the tagged templates stuff, it would just be astring => VNode
transformer.In case if you need htm-compatible API, have a look at xhtm https://github.com/spectjs/xhtm
On Tue, Sep 22, 2020 at 5:31 AM Kamil Tomšík notifications@github.com wrote: