HTML Void Elements List
The `html-void-elements` library provides a Pythonic list of all known HTML void tag names, based on the HTML living standard. Void elements are a special category of HTML elements that do not have closing tags and cannot contain any content or child elements (e.g., `<img>`, `<br>`, `<meta>`). This library is currently at version `0.1.0` and offers a static list for use in parsers, validators, or other HTML processing tools. Its release cadence is infrequent, typically updating only when the underlying HTML standard for void elements changes.
Warnings
- gotcha The package imports the list from `HtmlVoidElements` (capitalized) instead of `html_void_elements` (lowercase) directly. Ensure you use `from HtmlVoidElements import html_void_elements` for correct access.
- gotcha The list includes both modern and 'ancient' HTML void tag names (e.g., 'basefont', 'bgsound') based on the comprehensive HTML living standard. If you require a list limited to only currently recommended or widely supported void elements, you may need to filter this list manually.
- gotcha In HTML5, a trailing slash in void elements (e.g., `<img />`) is entirely optional and is ignored by HTML parsers. Using it does not make the tag 'self-closing' in the XML sense within HTML. Misunderstanding this can lead to incorrect expectations about HTML parsing behavior or validation.
Install
-
pip install html-void-elements
Imports
- html_void_elements
from HtmlVoidElements import html_void_elements
Quickstart
from HtmlVoidElements import html_void_elements print(html_void_elements) # Expected output: A list of strings, e.g., ['area', 'base', 'br', 'col', 'embed', ...]