Search code examples
htmltemplatestumblr

Can I have a <pre> Tag inside a <p> tag in Tumblr?


today I played around a little bit with Tumblr. I tried to add a preformatted text into a description paragraph block like so:

{block:Description}
    <p id="description">{Description}</p>
{/block:Description}

However, the <pre> element gets rendered just after the <p> element and not within it which was my intention.

Am I doing something wrong here or is it a bug?


Solution

  • You cannot nest block-level elements, such as <pre>, inside <p> in HTML, so Tumblr is behaving correctly. You should close your paragraph before inserting the pre-formatted text.

    If you want inline code-style text, try the <code> tag. You can then supplement it with CSS if needed.

    <p>I like to use the <code>code</code> tag in my HTML files.</p>
    
    code
    {
        padding: 2px 4px;
        color: #000000;
        background-color: #eeeeee;
        border-radius: 3px;
    }