Exercise - Creating a Basic HTML Page
Create a basic HTML page that has:
- The basic HTML5 declaration.
- The basic page structure.
- The required metadata elements.
Solution
The index.html source code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Page Title</title>
</head>
<body>
</body>
</html>
Explanation
This HTML page starts with the basic HTML5 declaration:
<!DOCTYPE html>
And it has the usual <html>, <head> and <body> sections, where the <head> and <body> elements are placed inside the <html> element:
<html lang="en">
<head>
</head>
<body>
</body>
</html>
Inside the <head> section, we placed the following required metadata elements:
- The meta charset element, set to the UTF-8 encoding.
- The meta viewport element.
- And a page title.
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Page Title</title>
</head>
This HTML page can serve as a skeleton, a starting point for all future HTML pages. In the next exercise, we will include additional metadata on our page.