Setting Up Your First HTML Page
To create a functioning webpage or website, you need to follow a basic structure and include key elements. Below is a breakdown of what you need to get started:
Key Elements of an HTML Page
1. Doctype Declaration
The `<!DOCTYPE html>` declaration specifies that the document is an HTML5 document:
<!DOCTYPE html>
2. Basic HTML Structure
Every HTML page needs the following structure:
<html>
<head>
<title>Page Title</title>
</head>
<body>
Page content goes here.
</body>
</html>
3. The Head Section
The `<head>` section contains metadata and links to resources like stylesheets:
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<title>Website Title</title>
</head>
4. The Body Section
The `<body>` section contains the visible content of the webpage:
<body>
<header>
<h1>Welcome to My Website</h1>
</header>
<main>
<p>This is the main content area.</p>
</main>
<footer>
<p>Footer content goes here.</p>
</footer>
</body>
Best Practices for Building a Website
Use semantic HTML tags (` <header>`, `<main>`, `<footer>`, etc.) to define content areas clearly.
- Include a `<meta name="viewport">` tag for responsive design on mobile devices.
- Keep styles in a separate CSS file for maintainability.
- Organize your files (e.g., HTML in the root, CSS in a `css` folder, images in an `img` folder).
- Validate your HTML using the W3C Validator.