How to Print Hello World in Html

Title: Getting Started with HTML: Printing “Hello, World!”

Introduction:

HTML (Hypertext Markup Language) is the backbone of the web, used to structure and present content on the internet. One of the simplest tasks in web development is printing “Hello, World!” on a webpage. In this article, we’ll guide you through the basic steps to achieve this using HTML.

Step 1:

Setting Up Your HTML File To get started, create a new HTML file using a text editor like Notepad, Sublime Text, or Visual Studio Code. You can name the file whatever you like, but it should have a .html extension. For example, hello.html.

Step 2:

Writing the HTML Code Once you’ve created the file, open it in your text editor and add the following code:

html

 

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

 

Let’s break down what each part of this code does:

  • <!DOCTYPE html>: This declaration defines the document type and version of HTML being used.

  • <html lang="en">: The opening tag for the HTML document. The lang="en" attribute specifies the language of the document (English, in this case).

  • <head>: This section contains metadata about the document, such as the character encoding and the title of the page.

  • <meta charset="UTF-8">: Specifies the character encoding for the document as UTF-8, which supports most characters from all languages.

  • <meta name="viewport" content="width=device-width, initial-scale=1.0">: Sets the viewport properties to ensure proper rendering and scaling on various devices.

  • <title>Hello, World!</title>: Sets the title of the webpage, which appears in the browser tab.

  • <body>: This is the main content of the webpage.

  • <h1>Hello, World!</h1>: This is a heading element (<h1>) that contains the text “Hello, World!”.

Step 3:

Saving and Previewing After adding the code, save the file. Now, you can open the file in your web browser to see the result. Right-click on the file and select “Open with” and choose your preferred browser, or simply double-click the file.

Conclusion:

Congratulations! You’ve successfully created a simple HTML document that prints “Hello, World!” on a webpage. This basic example is the foundation of web development, and from here, you can explore and learn more about HTML and other web technologies to create more complex and interactive web pages. Happy coding!

Reference: Chatgpt

 

error: Content is protected !!
Scroll to Top
MacroNepal
Verified by MonsterInsights