Understanding the Document Type Declaration
The first line of your HTML document should be the Document Type Declaration (DTD). This declaration specifies the version of HTML you’re using. For modern HTML5, the DTD is:
<!DOCTYPE html>
HTML Structure
A basic HTML document typically consists of three main sections:
- <head>: Contains metadata about the page, such as the title, stylesheets, and scripts.
- <title>: Sets the title of the page, which appears in the browser’s tab or title bar.
- <body>: Contains the visible content of the page, including text, images, and other elements.
Example:
<!DOCTYPE html>
<html>
<head>
<title>My Responsive Website</title>
<link rel=”stylesheet” href=”styles.css”>
</head>
<body>
</body>
</html>
Best Practices
- Use meaningful titles: Choose descriptive titles that accurately reflect the content of your page.
- Link to stylesheets: Include a <link> element to link your HTML document to an external stylesheet file.
- Structure your content: Use appropriate HTML elements to organize your content logically.
- Optimize for SEO: Use meta tags to provide information about your page to search engines.
Following these guidelines and starting your HTML pages correctly’ll lay a solid foundation for creating responsive and well-structured websites.