How can I get a p tag to appear in a document?

How can I get a p tag to appear in a document? For example, I want the code
<p>``<p>Hello World </p>``</p>
To appear as <p>Hello World </p> on the document but it will only appear as “Hello world”. Thanks

There is no proper solution to this imo.
What you can do is to:

  1. Replace the < character with &lt;
  2. Replace the > character with &gt;

Putting it together to your case it would be:

<p>&lt;p&gt;Hello World&lt;/p&gt;</p>

which is of course quite ridiculous.
Hope it helps!

Cheers

1 Like

Thanks, Ive been trying to figure that one out for quite a while. Much appreciated.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script>
    function myFunction()
    {
      document.getElementById("p1").innerText = "<p>Hello World</p>";
    }
  </script>
</head>
<body>
  <p id="p1" onclick="myFunction()" style="background-color: greenyellow; height: 100px;width: 200px"></p>
</body>
</html>