🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Expert Masterclasses.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
REFERENCEhtml

html Documentation

LOADING ENGINE...

"Hello World" in HTML

Your first step to creating web pages with the basic structure of HTML.

The Basic "Hello World" Code

Creating a "Hello World" is the traditional first step in programming. For HTML, it involves creating a minimal, valid web page that displays the text "Hello World".

Code:

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

Result:

Hello World

Breaking Down the Structure

  • `<!DOCTYPE html>`: Declares that the document is an HTML5 file. This must be the very first thing in your document.
  • `<html>`: The root element of an HTML page. The `lang` attribute specifies the page language.
  • `<head>`: Contains meta-information about the page, such as the title, character set, and links to stylesheets. This content is not displayed on the page itself.
  • `<body>`: Contains all the visible content of the web page, such as headings, paragraphs, images, and links.
  • `<h1>`: A top-level heading. The text inside will be displayed prominently on the page.

Common Variations

Once you have the basic structure, you can easily add more content.

Code:

<body>
  <h1>Hello World</h1>
  <p>This is my first paragraph.</p>
</body>

Result:

Hello World

This is my first paragraph.

Best Practices

  • Save with `.html`: Always save your files with the `.html` or `.htm` extension.
  • Use a Code Editor: Use a modern text editor like VS Code or Sublime Text for features like syntax highlighting and auto-completion.
  • Proper Indentation: Indent nested tags to make your code more readable and easier to maintain.