Introduction
Learning HTML is the first step for many aspiring web developers. One of the simplest projects to start with is creating a basic webpage that displays "Hello World". This guide walks you through writing the essential HTML source code.
Step 1: Set Up a Basic HTML Document
Every HTML document follows a standard structure. Create a new file with a .html extension, for example, index.html. Open it in any text editor and add the following code:
<!DOCTYPE html>
<html>
<head>
<title>My First Page</title>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
Step 2: Understanding the Code
<!DOCTYPE html>declares the document as HTML5.<html>is the root element.<head>contains meta-information like the page title.<body>holds the actual content visible to users.<h1>defines a top-level heading.
Step 3: View Your Page
Save the file and open it in any web browser. You should see "Hello World" displayed prominently. Congratulations—you've created your first HTML page!
Customizing the Display
To add a paragraph instead of a heading, replace the <h1> tag with <p>Hello World</p>. You can also center the text using inline CSS:
<p style="text-align:center;">Hello World</p>
Conclusion
Writing "Hello World" in HTML is a quick and rewarding exercise. It introduces you to the fundamental structure of web pages. From here, you can explore adding images, links, and styles to build more complex sites.