First HTML Program:
To create your first HTML program, you need a simple text editor like Notepad on Windows, TextEdit on macOS, or any code editor of your choice.
Here's a basic example of an HTML program:
1. Open your text editor.
2. Type the following HTML code:
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My First HTML Program</title>
</head>
<body>
<h1>Hello, World!</h1>
<p>This is my first HTML program.</p>
</body>
</html>
First HTML Program |
3. Save the file with an .html extension, for example, index.html.
4. Open the saved HTML file in a web browser.
HTML file |
Explanation of First HTML Program:
<!DOCTYPE html>: Declares the HTML5 document type.
<html lang="en">: The root element of the HTML document, with the language attribute set to English.
<head>: Contains meta-information about the HTML document, such as character set and viewport settings.
<meta charset="UTF-8">: Specifies the character encoding as UTF-8.
<meta name="viewport" content="width=device-width, initial-scale=1.0">: Configures the viewport for better responsiveness on various devices.
<title>: Sets the title of the HTML document, which appears in the browser tab.
<body>: Contains the content of the HTML document.
<h1>: Defines a top-level heading.
<p>: Defines a paragraph.
This example creates a simple webpage with a heading ("Hello, World!") and a paragraph. When you open the HTML file in a web browser, you'll see the rendered content.