Burak Arslan schrieb am 16.09.2014 um 10:12:
Void elements are html tags that don't need a closing tag. <br> is a well known example:
from lxml.builder import E html.tostring(E.br())
<p> is not a void element, so:
see the full list:
While working on etree.htmlfile, I noticed that the following tags are not treated as void:
embed, keygen, source, track, wbr
because of this, lxml can produce invalid html.
It's libxml2 serialising them, though. lxml has no word in this.
OTOH, it might be a good idea to make xf.element() aware of self-closing tags in HTML mode and let it a) write them out without closing tag and b) raise an exception when users attempt to write content into them.
You'd then write
with xf.element('meta', ...): pass
which isn't really worse than
That's another inconsistency, because the latter would still serialise some self-closing elements with closing tags. But I still consider it an improvement to provide a way for users to get it right at all.