Lesson 2 of 23

In progress

Course progress

HTML and CSS

Your first HTML page

Write a complete HTML document, understand the head and body, and open the result in a browser without a build step.

A web page is a text file with a few required parts. You do not need a framework, a package manager or a build step to make one, and starting with a plain file teaches you what the tools later hide.

What you will learn

  • Write the five parts every HTML document needs.
  • Tell what belongs in the head and what belongs in the body.
  • Save and open the file without a server.

The smallest complete document

HTML
Editable. Runs in your browser.





Press Run to see the output.

Five parts earn their place:

  • <!DOCTYPE html> selects standards mode. Without it, browsers use a legacy mode with different sizing rules.
  • <html lang="en"> is the root element. The language helps screen readers pronounce text and helps search engines.
  • <head> holds information about the page: character encoding, viewport, title and links to stylesheets.
  • <body> holds everything a visitor sees.
  • <title> names the page in the tab and in search results.

meta charset="utf-8" should be the first thing in the head. Without it, characters such as ₹ or accented letters can arrive garbled.

head and body are different jobs

The head is metadata. Nothing in it is displayed in the page area. The body is content.

A useful test: if you would not want it read aloud as part of the article, it probably belongs in the head. Titles, descriptions, icons, stylesheets and scripts go there. Headings, paragraphs, images, forms and links go in the body.

Only one title is allowed. It should describe the specific page, not just the site: "Reading lists in Python" beats "Tutorials".

Write it in a plain editor

Create a folder, add a file named index.html, paste the document and save it as UTF-8. Double-click it and your default browser opens it with a file:// address.

Then edit the text, save and refresh. That loop — edit, save, refresh — is the whole workflow for this track. A code editor adds syntax colouring and auto-closing tags, but it is not required.

The name index.html is a convention: servers use it as the default file for a folder. about.html is fine for a second page; index.html is what makes a folder addressable as a site.

Structure is visible even without styling

Browsers apply default styles: headings are large and bold, paragraphs have space above and below, lists get bullets. Those defaults exist so an unstyled page is still readable.

Do not use them as decoration. A heading is a heading because it names a section, not because you want large text. If you want large text for a slogan, that is a styling decision, and it will be handled with CSS.

HTML
Editable. Runs in your browser.





Press Run to see the output.

The h2 is not smaller because it is less important; it is smaller because it belongs under the h1. Browsers style heading levels by depth, which is why skipping levels for appearance confuses assistive technology.

Indentation and case

HTML is not whitespace-sensitive: extra spaces and newlines between elements collapse. Indent nested elements by two spaces for your own reading, not for the browser.

Tag names are case-insensitive, but lowercase is the convention and the only style you will see in professional code. Attribute values should be quoted, even when a browser would forgive the omission.

Saving a file as page.html.txt because the editor added an extension is common on Windows, where extensions are hidden. The browser then shows raw text or downloads the file. Turn on file extensions and confirm the name ends in .html.

Write a complete document with your name as the h1, a one-sentence paragraph about why you are learning, and a second-level heading "Goals" with a short paragraph underneath. Give the page a descriptive title.

Show solution
HTML
Editable. Runs in your browser.





Press Run to see the output.

The exact words do not matter. The structure does: doctype, language, head with encoding, viewport and title, then body content with a single h1 and an h2 beneath it.

Recap

  • Every document needs a doctype, a root html with lang, a head, a body and a title.
  • The head describes the page; the body contains what visitors read.
  • Save as .html in UTF-8, then use the edit, save, refresh loop.

Next, you will give text a proper outline with headings and paragraphs.

Do I need to close every tag?
You should. Some closing tags can be omitted in specific cases, but relying on that makes the file harder to read and easy to break. Write both tags and let the editor help.
Where do CSS and JavaScript files go?
Link the stylesheet in the head with a link element, and put scripts at the end of the body or use the defer attribute. The next module covers both in context.

Full syllabus

Progress is saved in this browser only. No account, no email.

Admin

About the author

Admin

Instructor and technical writer at tutorials.in

Writes beginner lessons for tutorials.in. Each lesson is checked against the language or tool documentation, and examples are run before publishing.

Reviewed by the editorial team before publishing. Last updated November 16, 2026.