SpartanGolf
SpartanGolf

Reputation: 15

How to display multiple lines of text in HTML

I want to write a website that shows what code is needed to output "Hello world" in multiple coding languages. I want to include HTML Code, but I don't want the program to think it is more code being nested inside the program, and I need it to be printed like this:

<html>
  <head>
    <h2>How to print 'Hello World' in # of coding languages
</head>
<body>
    <h6> HTML 5 </h6>
    <p> 'Hello World' </p>
</body>
</html>

I want it to show the code for printing 'Hello World' when it's running, but I don't know if I need to use .

or something else, as I just learned HTML this month, and I am coming from Python.

This is my code:

<!DOCTYPE html>
<html>
<body>
  <h1> How to write 'Hello World' in ____ coding languages </h1>

  <h4> HTML </h4>
  <p>
      <p> <!DOCTYPE html>
  <br>
    <html>
  <br>
    <head>
  <br>
    </head>
  <br>
    <body>
  <br>
    <p> Hello World </p>
  <br>
    </body>
  <br>
    </html>
  </p>
</body>

My expected output is the code for a website showing 'Hello World' but it outputs:

Hello World

I'm sorry if this is confusing, I don't have a good way to explain what my goal for this project.

Upvotes: 0

Views: 1739

Answers (1)

Try this. I just replaced < by &lt; and > by &gt;

<!DOCTYPE html>
<html>
<body>
  <h1> How to write 'Hello World' in ____ coding languages </h1>

  <h4> HTML </h4>
  <p>
      <p> &lt;!DOCTYPE html>
  <br>
    &lt;html &gt;
  <br>
    &lt;head &gt;
  <br>
    &lt;/head &gt;
  <br>
    &lt;body &gt;
  <br>
    <p> Hello World </p>
  <br>
    &lt;/body &gt;
  <br>
    &lt;/html &gt;
  </p>
</body>

Upvotes: 1

Related Questions