mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-03 21:36:36 +00:00
Strange behavior when writing divs in a custom renderer #760
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @minisbett on GitHub (Oct 18, 2025).
I have a custom renderer which, for demonstration purposes, writes something along the lines of this:
However, in the rendered HTML, the very same code looks like this:

It seems to
a-tag, and places it there, just completely empty.div-tag in thea-tag, and places it on the root layer as well, then putting thea-tag inside, which then contains everything thedivcontained.This seems very strange, and I've tried a lot, always running into this issue when using
div-tags. Is this intended behavior? Something I am not aware of?@xoofx commented on GitHub (Oct 19, 2025):
Your problem is not related to Markdig but an invalid usage of HTML. By default,
<a>tag is an inline HTML element, which cannot contain a block element like<div>. Browsers will accept whatever you throw at them, even invalid HTML like this, but they will try to arrange things with convoluted rules (sometimes browser specifics).@minisbett commented on GitHub (Oct 19, 2025):
This is only correct in HTML 4. HTML 5 onwards states:
I'm really confused why my browser decides to do this. But yes, I was able to confirm that it is indeed not a Markdig issue.
Edit: I've dug a bit deeper, and eventually figured that the problem is that the renderer writes the HTML into a p-tag.