Skip to main content
D
HTML
HTML Basic Examples

HTML Basic Examples

HTML files require a specific structure to work correctly.

Read Time
5 min read
Difficulty
Beginner
Last Updated
Jun 15, 2026
Version
v1.0.0

Introduction

HTML files require a specific structure to work correctly. A doctype declaration tells the browser to expect HTML5. The html element wraps all other content on the page.

Syntax

Syntax
1<!DOCTYPE html>
2<html lang="en">
3  <head>
4  </head>
5  <body>
6  </body>
7</html>

Example

Example
1<!-- this defines a basic html file -->
2<!DOCTYPE html>
3<html lang="en">
4  <head>
5    <meta charset="UTF-8">
6    <meta name="viewport" content="width=device-width, initial-scale=1.0">
7    <title>My Page</title>
8    <link rel="stylesheet" href="styles.css">
9  </head>
10  <body>
11    <h1>Hello, World!</h1>
12    <p>Welcome to my first web page.</p>
13    <script src="app.js"></script>
14  </body>
15</html>

Try it Yourself

Hands-on Practice
Modify the code below to see how it affects the output. This is the best way to learn!
Interactive Editor
1234567891011121314151617181920
Live Preview

Key Points

  • The doctype declares the document version.
  • The html element contains all page content.
  • The head holds hidden metadata.
  • The body contains visible elements.

Up Next

Continue your journey with the next topic.

Go to HTML Elements