HTML is the starting point of all web development. A browser reads an HTML file and displays the page that it describes.

What is HTML

HTML (HyperText Markup Language) is the standard language for creating web pages. HyperText means text that contains links to other text, so that the reader can jump from page to page. Markup means that the content is marked with tags that describe its structure. HTML is not a programming language: it has no variables or loops; it describes what each part of the page is, while CSS describes how it looks and JavaScript describes how it behaves.

Definition: HTML. HyperText Markup Language, the standard markup language that describes the structure and content of web pages using elements written as tags.

History of HTML

HTML was created by Tim Berners-Lee at CERN in 1991, together with the first web browser and server. HTML 2.0 (1995) was the first standard. HTML 3.2 (1997) added tables, and HTML 4.01 (1999) added style sheets and scripts. XHTML 1.0 (2000) applied the strict rules of XML to HTML. HTML5, finalised by the W3C in 2014, added semantic tags such as header, nav and footer, audio and video, the canvas element, new form input types and local storage. HTML is now maintained as a "living standard" by WHATWG.

Objectives of HTML

HTML aims to: describe the structure of documents in a simple, platform-independent way; link documents across the internet; embed images, audio and video; collect user input through forms; and work with CSS for presentation and JavaScript for behaviour.

Elements, Tags and Attributes

An element usually has a start tag, content and an end tag: <p>Hello</p>. Some elements are empty (void), with no content or end tag, such as <br>, <hr> and <img>. Attributes give extra information and are written in the start tag as name="value": <a href="page.html">. Tag names are not case-sensitive, but lower case is the convention. Elements can be nested, and must be closed in the reverse order of opening.

Basic Structure of an HTML Document

Every HTML5 document has the same skeleton. <!DOCTYPE html> tells the browser that this is an HTML5 document. <html> is the root element, often with lang="en". The <head> contains information about the page that is not shown in its body, such as the <title> shown in the browser tab, <meta charset="UTF-8"> for the character set, the viewport meta tag for mobile devices, and links to style sheets and scripts. The <body> contains everything that is displayed. HTML files are saved with the extension .html or .htm and opened in a browser.

Table 1.1: Versions of HTML

Version Year Main addition
HTML 2.0 1995 First standard
HTML 3.2 1997 Tables
HTML 4.01 1999 Style sheets and scripts
XHTML 1.0 2000 Strict XML rules
HTML5 2014 Semantic tags, audio, video, canvas

Example 1.1: A first web page

Problem: Write a complete HTML5 page with the title "My First Page", a heading and a paragraph.

Solution:

  1. Start with <!DOCTYPE html> and the <html> root.
  2. In <head>, give <meta charset>, the viewport meta tag and <title>.
  3. In <body>, write an <h1> heading and a <p> paragraph.
  4. Save it as index.html and open it in a browser.

Result: The browser shows the heading and paragraph, with "My First Page" on the tab.

<!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 Web Technologies</h1>
  <p>This page is written in HTML5.</p>
</body>
</html>

Common mistakes

  • Leaving out <!DOCTYPE html>, which makes browsers use an older "quirks" mode.
  • Putting visible content inside <head>.
  • Closing nested tags in the wrong order, as in <b><i>text</b></i>.

Key takeaways

  • HTML describes the structure of a page with tags.
  • An element has a start tag, content and an end tag; attributes go in the start tag.
  • A page has <!DOCTYPE html>, <html>, <head> and <body>.
  • HTML5 added semantic tags, media and new form inputs.

Practice questions

  1. What does HTML stand for?
  2. Who created HTML?
  3. What goes in the head of a document?

Answers to the practice questions

  1. HyperText Markup Language.
  2. Tim Berners-Lee, at CERN, in 1991.
  3. Information about the page, such as the title, meta tags and links to style sheets and scripts.

Sources

  • Official BCA syllabus Web Technologies, course code 25BCA402SEC02, Unit I