Write Your First HTML Document:
Here's a simple example of a basic HTML document. Copy and paste this code into a text editor (like Notepad on Windows, TextEdit on macOS, or Visual Studio Code) and save it with an `.html` file extension. You can then open it in a web browser to see the rendered output.
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 Document</title>
</head>
<body>
<header>
<h1>Welcome to My First HTML Document</h1>
</header>
<main>
<p>This is a simple paragraph in the main content section.</p>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
</main>
<footer>
<p>© 2023 Your Name</p>
</footer>
</body>
</html>
Write Your First HTML Document |
Explanation:
- `<!DOCTYPE html>`: Declares the document type and version of HTML.
- `<html lang="en">`: The root element of the HTML document. "en" denotes the language (English).
- `<head>`: Contains meta-information about the HTML document, such as character set and viewport settings.
- `<meta charset="UTF-8">`: Specifies the character encoding (UTF-8) for the document.
- `<meta name="viewport" content="width=device-width, initial-scale=1.0">`: Sets the viewport properties for responsive design.
- `<title>`: Sets the title of the HTML document (appears in the browser tab).
- `<body>`: Contains the main content of the HTML document.
- `<header>`, `<main>`, `<footer>`: Sections of the HTML document for organization.
- `<h1>`: Heading tag indicating the main heading of the document.
- `<p>`: Paragraph tag for text content.
- `<ul>` and `<li>`: Unordered list and list items.
Feel free to customize the content and experiment with additional HTML elements as you learn more about web development!