CHAPTER 02 · HTML

What HTML does: content, meaning and the other web languages

HTML helps you describe the information on a page. In this chapter, you will learn why it exists, what its name means and how it works alongside CSS and JavaScript. You will also see what a plain HTML page can and cannot do.

Download example files (ZIP)

What you will learn

  • Explain HTML without memorising a difficult definition.
  • Read a small heading and paragraph example.
  • Tell a tag, an element and an attribute apart at an introductory level.
  • Choose whether a requirement belongs to HTML, CSS, JavaScript or a server.
  • Avoid confusing a plain-looking page with a broken page.

Why do we need HTML?

Suppose you type three lines in a plain text file: a notice title, an explanation and a contact detail. A human may guess their roles. A browser needs a reliable way to recognise those roles. HTML supplies agreed names for them.

With HTML, you can say that some text is a heading, another part is a paragraph and another part is a link. That meaning helps browsers and other tools work with the content. For example, software that reads a page aloud can use properly chosen headings to help a reader move through it.

HTML describes the content and structure of a web page. Structure means how its parts are organised and related. Think of a college notice: its title identifies the subject, and its paragraphs explain the details.

What the name means

HTML stands for HyperText Markup Language.

  • Hypertext is content connected through links. A link can take you to another document or a place within a document.
  • Markup is the use of markers to describe parts of the content. In HTML, many of those markers are tags such as <p>.
  • Language means an agreed set of names and writing rules that browsers understand.

You do not need to repeat the full name every time you build a page. It is more useful to know what a heading means and how to write it correctly.

Your first small pieces of HTML

HTML fragment — part of a document
<h1>Weekend study group</h1>
<p>We will revise one topic together each Saturday.</p>

This is a fragment, which means part of a document. It is useful for studying one idea, but it does not show the complete file structure. We label complete files with a .html filename and show their browser previews.

In <p>We will revise one topic together each Saturday.</p>:

  • <p> is the opening tag. It starts the paragraph.
  • The sentence is the content.
  • </p> is the closing tag. The slash marks the end.
  • The whole paragraph, including its tags and content, is an element.

The tag is a marker; the element is the part described by that marker. You will study tags and nesting fully in Chapter 6. For now, notice that the names at both ends match.

Extra information: an attribute

An attribute adds information to an element. We will use a small example that appears in every complete file:

HTML fragment — part of a document
<html lang="en">

Here, lang is the attribute name and en is its value. Together, they say that the document's main language is English. This does not translate the page into English. It tells tools how to interpret the language the author has written.

We put the value inside straight quotation marks. Attribute names and values will have a separate chapter; you only need this one introduction to read our example files.

HTML, CSS and JavaScript have different jobs

CSS is used to control appearance and layout. Layout means the arrangement of things on a page. CSS can change colours, spacing and how columns fit on a screen.

JavaScript is a programming language that can change content and respond to actions. For example, it can calculate a practice score after someone answers questions.

Three tools that work together
  1. 1HTML: describe the content
  2. 2CSS: arrange and style it
  3. 3JavaScript: add application behaviour

HTML already supports links and other built-in behaviour. Saving submitted information reliably usually needs a receiving service too.

RequirementMain tool or responsibilityWhy
Mark a notice title as a headingHTMLDescribes what the text is
Make the notice card blueCSSChanges appearance
Calculate a score in the browserJavaScriptPerforms a calculation and updates the view
Store a submitted application reliablyA server and suitable storageKeeps and checks information beyond one displayed page

This table gives common responsibilities, not absolute limits on every feature. HTML itself includes useful behaviour, such as following links and basic form checks. A form can submit without JavaScript when a server is ready to receive it. We will learn those features later.

Is HTML a programming language?

HTML is normally called a markup language, not a general-purpose programming language. It describes documents. It does not provide ordinary instructions such as loops and arithmetic functions for writing an application.

That does not make HTML unimportant. A page can look attractive and still be hard to use if its content is organised badly. Choosing the correct element is a real skill.

For example, choosing a heading because it means a heading is better than choosing it only because it appears large. CSS should handle the preferred visual size.

A complete example: a skill-sharing session

skill-session.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Skill-sharing Session</title>
</head>
<body>
  <h1>Share one skill</h1>
  <p>Each student will explain one useful computer shortcut.</p>
  <p>Bring a notebook and one question.</p>
</body>
</html>
Browser previewDocument title: Skill-sharing Session

This preview shows the example in a browser. Save the complete code in local files to test links between pages and downloads. Same-page section links work here.

The browser preview contains a heading and two paragraphs. No CSS or JavaScript is needed to display them. The browser applies its own starting appearance, such as text sizes and margins. A margin is space around an element.

Read the example as a message. The heading states the activity; the first paragraph explains it; the second tells readers what to bring. That is the problem the page solves.

Problem and solution: separate three requests

Problem: a student club asks for a page with a session notice, a blue background and a count of days until the session.

Solution: first write the notice in HTML. Then use CSS for the background. Use JavaScript if the count must be calculated and updated in the browser. If students must register and the registration must be saved, plan the server work as well.

You do not have to learn all these tools today. Being able to separate the jobs will stop you from searching for an HTML tag that is supposed to do every task.

What HTML alone does not promise

  • A beautiful design: default browser styling is only a starting point.
  • A saved account: an input field does not create a working registration system by itself.
  • Identical appearance everywhere: fonts, browser settings and screen sizes vary.
  • Privacy for hidden information: visitors can inspect downloaded HTML. Do not place passwords or private keys in it.
  • Correctness just because something appears: browsers can recover from some writing mistakes.

Common mistakes and useful tips

  • Calling HTML a tool for every calculation: choose the tool that fits the job.
  • Thinking CSS replaces HTML: CSS styles a document; it does not remove the need for meaningful content.
  • Believing JavaScript is needed to show a paragraph: plain HTML already supports that.
  • Using heading elements only to make text large: describe the role first, then style it later.
  • Copying code without reading the message it creates: ask whether a visitor would understand it.

Practice questions

  1. Explain HTML to a friend in one sentence without using the word markup.
  2. In <p>Bring your notebook.</p>, identify the opening tag, content and whole element.
  3. What information does lang="en" provide? Does it translate text?
  4. Which tool would normally change the space between two paragraphs?
  5. Can the complete skill-sharing example display without JavaScript?
  6. A club wants to keep submitted registrations after the browser closes. Why is a form's HTML alone not enough to promise this?
Check your practice answers
  1. HTML tells a browser how the content of a web page is organised, such as which text is a heading or paragraph.
  2. <p> starts the paragraph, Bring your notebook. is its content, and the full marked paragraph is the element.
  3. It identifies English as the main language for that element and its content unless overridden. It does not translate the words.
  4. CSS normally controls that spacing.
  5. Yes. It is a complete document with text content and no script dependency.
  6. A form can describe fields and submit values, but a service must receive, check and store them if reliable saved registrations are required.

Interview questions

What is HTML used for?

It describes the content and structure of web documents. For example, it can identify a notice heading, paragraphs, links and form controls.

How are HTML and CSS different?

HTML describes the parts and their meaning. CSS controls their appearance and layout. A paragraph remains a paragraph even when its colour changes.

Are a tag and an element the same thing?

They are related but different. A tag is a marker such as <p>. A paragraph element includes its content and the tags that describe it. Some elements, such as meta, have no closing tag or child content in HTML.

Why learn meaningful HTML if a browser can display poorly written markup?

Visible output is only one check. Clear structure helps accessibility, maintenance and predictable behaviour. Browser recovery does not turn every mistake into a good document.

Quick revision

  • HTML describes content and its organisation.
  • Tags mark elements; attributes supply extra information.
  • CSS controls appearance, and JavaScript can add application behaviour.
  • HTML includes some built-in behaviour; it is not just a picture of a page.
  • A complete application may also need a server and storage.
  • Build a clear document before worrying about decoration.