<source> and <track> are void elements in HTML 5

Bug #1758553 reported by Vincent Bernat on 2018-03-24
This bug affects 1 person
Affects Status Importance Assigned to Milestone

Bug Description


In HTML5, the void elements are listed here: https://www.w3.org/TR/html5/syntax.html#void-elements. This doesn't match the list in src/lxml/html/defs.py. Notably, <source> and <track> are in html5_tags instead.

scoder (scoder) wrote :
Changed in lxml:
assignee: nobody → scoder (scoder)
milestone: none → 4.4.0
status: New → Fix Committed
scoder (scoder) on 2019-07-27
Changed in lxml:
status: Fix Committed → Fix Released
Vincent Bernat (vbernat) wrote :


Sorry for not testing earlier, but it doesn't seem to work:

>>> from lxml import etree as ET
>>> import lxml.html
>>> lxml.html.tostring(ET.Element("source"))
>>> lxml.html.tostring(ET.Element("img"))

Maybe these tags should be removed from `html5_tags`? All other tags from `empty_tags` are part of another set. Dunno, if this is mandatory.

scoder (scoder) wrote :

The serialisation is done by libxml2. defs.py is mostly used by the cleaner and for informational purposes, not for serialisation.

Vincent Bernat (vbernat) wrote :

Thanks, I will push a similar fix to libxml2 then!

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers