question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support HTML5 void elements

See original GitHub issue

It 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:closed
  • Created 3 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
developitcommented, Sep 21, 2020

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 a string => VNode transformer.

0reactions
dycommented, Sep 22, 2020

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:

of folks thinking HTM is an HTML parser.

Of course it’s not, I’m using it only temporarily

BTW: @developit https://github.com/developit do you know about some small (well-formed is enough, speed is not an issue) HTML parsers?

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/developit/htm/issues/171#issuecomment-696611305, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACJIIZT4LL7I4WPU44A5B3SHBVGFANCNFSM4NZERNKA .

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found