How to Create a Basic HTML Page: Simple Guide for Beginners
To create a basic HTML page, start with a
<!DOCTYPE html> declaration, then add <html>, <head>, and <body> tags. Inside the <body>, add your content like headings and paragraphs. Save the file with a .html extension and open it in a browser to see the page.Syntax
A basic HTML page has a simple structure with these parts:
- <!DOCTYPE html>: Declares the document type as HTML5.
- <html>: The root element that wraps the whole page.
- <head>: Contains meta information like the page title.
- <title>: Sets the page title shown in the browser tab.
- <body>: Contains the visible content of the page.
html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Page Title</title> </head> <body> <!-- Your content goes here --> </body> </html>
Example
This example shows a complete basic HTML page with a heading and a paragraph. You can save this as index.html and open it in any web browser to see the result.
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 Page</title> </head> <body> <h1>Welcome to My Website</h1> <p>This is my first basic HTML page.</p> </body> </html>
Output
Welcome to My Website
This is my first basic HTML page.
Common Pitfalls
Beginners often forget the <!DOCTYPE html> declaration, which can cause browsers to render the page incorrectly. Another common mistake is missing the <meta charset="UTF-8"> tag, which can lead to strange characters showing up. Also, forgetting to save the file with a .html extension means the browser won't recognize it as a web page.
Always close your tags properly and use lowercase for tags to keep your code clean and consistent.
html
<!-- Wrong: Missing DOCTYPE and charset --> <html> <head> <title>Page</title> </head> <body> <h1>Hello</h1> </body> </html> <!-- Right: Includes DOCTYPE and charset --> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Page</title> </head> <body> <h1>Hello</h1> </body> </html>
Quick Reference
Here is a quick cheat sheet for the basic HTML page structure:
| Tag | Purpose |
|---|---|
| Defines the document as HTML5 | |
| Root element of the page | |
| Contains meta info and title | |
| Sets character encoding | |
| Page title shown in browser tab | |
| Visible content of the page |
Key Takeaways
Always start your HTML page with to ensure proper rendering.
Use , , and tags to structure your page correctly.
Include in the head to avoid character display issues.
Save your file with a .html extension to open it in browsers.
Keep your tags properly closed and use lowercase for consistency.