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?
<p> inside <p>You cannot nest P elements it is illegal. The P element represents a paragraph. It cannot contain block-level elements (including P itself). DIV however is a generic container where content can be inline e.g SPAN or block-level.
The p tag. This tag defines a paragraph of text. It's a block element. Inside it, we can add any inline element we like, like span or a .
The <p> tag defines a paragraph. Browsers automatically add some space (margin) before and after each <p> element while, the <pre> tag defines pre-formatted text. Text in a <pre> element is displayed in a font (usually Courier), and it preserves both spaces and line breaks.
Text in a <pre> element is displayed in a fixed-width font, and the text preserves both spaces and line breaks. The text will be displayed exactly as written in the HTML source code.
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;
}
Also, I just realized where I was having a similar issue pasting code into tumblr inside <pre>
and <code>
tags is that just because you wrap your code in those tags doesn't prevent you from having to escape the carets with <
and >
instead of the carets.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With