I have found an issue in this question: How to get list of values in GROUP_BY clause?

Check this out. I enter the following piece of HTML:


It is rendered as such:


When I check the rendered HTML in my browser, what I get is this:


So some extra <code/> element and paragraph are rendered.

  • 1
    It should be noted that that question is over three years old. These days, it's much easier to create correct Markdown (more help, better preview fidelity, fewer bugs...)
    – balpha StaffMod
    Apr 6, 2012 at 20:38
  • The code element is an inline formatting element, but inline elements in a page need to be within a block element. By default, if there's still no block element open containing your <code> element, a default block element will be inserted : the p element. Then comes a pre element, which is a block element. It has the effect of terminating the current block element (the "p" element is closed, but before doing that the current inline element code is temporarily closed, then the pre element is open, which whose content type allows the insertion of inline formatting elements.... Apr 7, 2012 at 1:16
  • So the "code" is reopened within the "pre" element, before inserting the rest of the content of your "pre" element. When the "pre" block element terminates, its current active inline formatting elements are first closed; then there only remains the "code" element closing tag, but as there's nothing more before it, the "code" element is not reopened and there's nothing more to generate. You should really learn about HTML containment rules, notably in HTML5 which is even more strict (and does not require the source to use strict encapsulation of tags: HTML5 is not XML ! Apr 7, 2012 at 1:22
  • Note that the first "p" element could have been not autogenerated, because there was no content to which apply the "code" element that it contains. Effectively there's nothing between your specified "code" opening inline tag, and the next "pre' opening block tag. So the result should have been just <pre><code>hello</code></pre> without anything before it. Your source document would be invalid in XHTML (incorrect containment according to XML schema of HTML), but it is valid in HTML4 and HTML5 where tags don't have to be closed, but where tags are implied according to the mandatory schema. Apr 7, 2012 at 1:25
  • So in summary, what you see in your browser is how it parsed your document when creating the DOM from your source file, it will be different from your source, by design. Read the HTML specfiications ! Apr 7, 2012 at 1:31
  • @PhilippeVerdy: Why not write a regular answer? Are you afraid of the formatter, too? :)
    – Lukas Eder
    Apr 7, 2012 at 7:55

1 Answer 1


No, these extra code elements are not rendered, they're added by the browser. If you look at the page source, you'll see this:


So the Markdown engine allows you to shoot yourself in the foot; however it's up to the browser how to handle this invalid HTML (phrase elements are inline elements and as such cannot contain block-level elements like <pre>).

If you decide to write your own HTML instead of using Markdown to do it for you, it's expected that you a) know about the HTML-in-Markdown rules (which also explain why you're getting the extra paragraph tags) and b) make sure you create valid HTML.

  • The browser adds the <p/> element? In any case, the user didn't...
    – Lukas Eder
    Apr 6, 2012 at 20:34
  • @LukasEder Then it wouldn't be visible in the page source. See point a) in my last paragraph.
    – balpha StaffMod
    Apr 6, 2012 at 20:36
  • I see, I didn't know block elements were forbidden inside of phrase elements... Thanks for the hint!
    – Lukas Eder
    Apr 6, 2012 at 20:38
  • No, @Lukas, the browser is not adding the <p> that balpha shows above, but the server is (when seeing <code><pre> in the Markdown source, but not when seeing <pre><code>). Next, the browser turns it into the HTML you showed.
    – Arjan
    Apr 6, 2012 at 20:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .