write "hello world"

Writing "Hello World" in HTML

If you are new to programming, writing "Hello World" is usually the first step to getting started. It's a simple program that displays the text "Hello World" on the screen. Here is how you can write it in HTML:

Method 1:


      <html>
        <head>
          <title>Hello World</title>
        </head>
        <body>
          <p>Hello World</p>
        </body>
      </html>
    

This code will display the text "Hello World" in a paragraph element within the body of an HTML document. The title element within the head section is optional but recommended for accessibility purposes.

Method 2:


      <html>
        <head>
          <title>Hello World</title>
        </head>
        <body>
          Hello World
        </body>
      </html>
    

This code will display the text "Hello World" directly within the body of an HTML document without using any tags. However, it is generally recommended to always use tags in HTML for accessibility and semantic reasons.

Method 3:


      <!DOCTYPE html>
      <html>
        <head>
          <title>Hello World</title>
          <meta charset="UTF-8">
          <meta name="viewport" content="width=device-width, initial-scale=1.0">
        </head>
        <body>
          <h1>Hello World</h1>
        </body>
      </html>
    

This code is similar to method 1, but includes a DOCTYPE declaration and additional meta tags for better performance and compatibility with different devices. It also uses a heading tag instead of a paragraph tag to display the text "Hello World".

Overall, these are just a few ways to write "Hello World" in HTML. Depending on your project or personal preference, you may choose to write it differently. However, as long as the code is valid and accessible, you should be good to go!

Subscribe to The Poor Coder | Algorithm Solutions

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
[email protected]
Subscribe