如何添加<pre> tag inside the <p> in html?

时间:2017-06-14 10:26:12

标签: html html5

I'm using below code it is throwing the <pre> outside the <p>. So, is there any way to insert <pre> inside <p>. below I'm attaching my code.

<!DOCTYPE html>
<html>
 <head>
    <title></title>
 </head>
 <body>
    <p>
      <pre>
        dkjaskldjasklda
        skladjasklda
      </pre>
   </p>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

<pre> is a block-level element and <p> is not. It's not possible to put block-level elements inside <p>.

If you use the <p> for creating whitespace, you can solve this by adding a margin-bottom to the <pre> tag.