# Bug or expected? Markdown sometimes doesn't work inside \`div\` tags

**URL:** <https://talk.commonmark.org/t/bug-or-expected-markdown-sometimes-doesnt-work-inside-div-tags/4378>\
**Category:** Spec\
**Created:** [January 25, 2023, 8:11pm UTC](https://talk.commonmark.org/t/bug-or-expected-markdown-sometimes-doesnt-work-inside-div-tags/4378 "2023-01-25T20:11:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pragy](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/pragy/32/2689_2.png) [@pragy](https://talk.commonmark.org/u/pragy)\
**Post date:** [January 25, 2023, 8:11pm UTC](https://talk.commonmark.org/t/bug-or-expected-markdown-sometimes-doesnt-work-inside-div-tags/4378/1 "2023-01-25T20:11:30Z")

</div>

There seem to be certain weird edgecases in which markdown doesn’t work inside HTML tags.

Is this a bug or an expected behavior? If it is expected, then what is the reason behind it?

Demo: [commonmark.js demo](https://spec.commonmark.org/dingus/?text=This%2C%20%3Cdiv%3E **Works** %20as%20expected%3C%2Fdiv%3E%0A%0A--%20--%0A%0ASo%20does%0A%0A%3Cspan%3E **this** %3C%2Fspan%3E%0A%0A--%20--%0A%0ABut%20%0A%0A%3Cdiv%20style%3D%22color%3A%20red%22%3E **this%20does%20not!** %20%3C%3D%3D%20Bug!%3C%2Fdiv%3E%0A)

Source:

```auto
This, <div> **Works** as expected</div>

-- --

So does

<span> **this** </span>

-- --

But 

<div style="color: red"> **this does not!** <== Bug!</div>

```

---

<div class="post-metadata">

**Author:** ![chrisalley](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/chrisalley/32/906_2.png) [@chrisalley](https://talk.commonmark.org/u/chrisalley)\
**Post date:** [January 27, 2023, 5:52am UTC](https://talk.commonmark.org/t/bug-or-expected-markdown-sometimes-doesnt-work-inside-div-tags/4378/2 "2023-01-27T05:52:37Z")

</div>

This looks like a bug, but unrelated to the style attribute. Using a non-span tag such as div or p when the tag starts a new line causes the problem.

```plaintext
x <p> **this appears as bold text** </p>

<p> **this does not appear as bold text** </p>

```

---

<div class="post-metadata">

**Author:** ![pragy](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/pragy/32/2689_2.png) [@pragy](https://talk.commonmark.org/u/pragy)\
**Post date:** [January 27, 2023, 9:59am UTC](https://talk.commonmark.org/t/bug-or-expected-markdown-sometimes-doesnt-work-inside-div-tags/4378/3 "2023-01-27T09:59:23Z")

</div>

What’s the procedure to getting this fixed in the future specs? I’m new to these forums. Thanks 🙂

---

<div class="post-metadata">

**Author:** ![chrisalley](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/chrisalley/32/906_2.png) [@chrisalley](https://talk.commonmark.org/u/chrisalley)\
**Post date:** [January 27, 2023, 6:03pm UTC](https://talk.commonmark.org/t/bug-or-expected-markdown-sometimes-doesnt-work-inside-div-tags/4378/4 "2023-01-27T18:03:43Z")

</div>

We ask @jgm, the author of the spec, if the behaviour is intentional or a bug. It appears to relate to whether the HTML tag is a block level tag or phrasing content (and some tags can be both).

Related discussion:

> [@Raw HTML blocks proposals -- comments wanted](https://talk.commonmark.org/t/raw-html-blocks-proposals-comments-wanted/983):
>
> The current spec for raw HTML blocks hard-codes a list of HTML “block-level” tags. This isn’t ideal, for several reasons: New tags may be added to HTML in the future If you use custom tags in your application, they’ll always be treated as span-level, which is often not what you want (see [https://github.com/jgm/CommonMark/issues/239](https://github.com/jgm/CommonMark/issues/239)). Some tags can be both span- or block-level (see [https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content\_categories#Phrasing\_content](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content)). The current system…

---

<div class="post-metadata">

**Author:** ![dbuenzli](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/dbuenzli/32/2353_2.png) [@dbuenzli](https://talk.commonmark.org/u/dbuenzli)\
**Post date:** [February 7, 2023, 11:28pm UTC](https://talk.commonmark.org/t/bug-or-expected-markdown-sometimes-doesnt-work-inside-div-tags/4378/5 "2023-02-07T23:28:45Z")

</div>

@chrisalley points the reason. This works according to the spec.

In this case:

```auto
x <p> **this appears as bold text** </p>

```

you have two [raw HTML](https://spec.commonmark.org/0.30/#raw-html) inlines `<p>` and `</p>`, and a strong emphasis inline between them.

In this case:

```auto
<p> **this does not appear as bold text** </p>

```

you have an [HTML block](https://spec.commonmark.org/0.30/#html-blocks) of type 6. An HTML block is a group of lines that whose data is not interpreted as markdown.
