HTML, which stands for HyperText Markup Language, is the language used to create web pages. Every website we visit, from school websites to online shops, is built using HTML. HTML is not a programming language in the usual sense; it is a markup language, which means it uses tags to describe how the content of a web page should be arranged and displayed. A web browser reads the HTML file and shows the content on the screen in a formatted way.
Learning HTML is the first step towards web development. With just a simple text editor such as Notepad and a browser, we can create our own web pages. This chapter explains what HTML is, the structure of an HTML document, common tags for headings, paragraphs, lists, images and links, the attributes of tags, and how to view an HTML page in a browser. These skills allow us to build simple but real web pages.
An HTML document has a fixed basic structure. It begins with the DOCTYPE declaration, which tells the browser that the document is written in HTML. The whole content is written inside the tag. The document is divided into two main parts: the head and the body. The
section contains information about the page, such as its title, which appears in the browser tab. The section contains all the content that is visible on the page.The basic structure looks like this: the tag opens the document, inside it the
tag holds theand a closing tag such as
. Some tags, likeHeadings are used to give titles to different sections of a web page. HTML provides six levels of headings, from
Paragraphs are written using the
and
tags. The text between these tags appears as a paragraph, with space above and below it. To break a line inside a paragraph, we use theHTML allows us to create lists, insert images and add links. There are two types of lists in HTML. An ordered list, written with the
Images are inserted with the tag. This tag is different from most others because it has no closing tag and it needs attributes. The src attribute gives the location of the image file, the alt attribute gives a text that is shown if the image cannot be displayed, and width and height set the size. Links are created with the anchor tag . The href attribute contains the address of the page we want to go to, and the text between and is the clickable link. For example, Click here creates a link.
Attributes give extra information to HTML tags. They are always written inside the opening tag, as a name and a value, such as href="https://example.com" or src="pic.jpg". Some important attributes are href for links, src and alt for images, width and height for sizing, and align for aligning content. Attributes make tags more useful by telling the browser exactly how to display the element.
After writing the HTML code, we save the file with the .html extension, such as mypage.html, and open it in any web browser by double-clicking it or using the browser's Open File option. The browser reads the tags and displays the formatted page. If we make a mistake, the browser may still show the page but with errors, so we should check our tags carefully. With practice, we can build complete web pages that combine text, headings, lists, images and links.
| Tag | Purpose |
|---|---|
| Root of the HTML document | |
| Information about the page | |
| Title shown in the browser tab | |
| Visible content of the page | |
to |
Six levels of headings |
| Paragraph | |
| Bold text | |
| Italic text | |
| Underlined text |
| Tag | Purpose | Important Attribute |
|---|---|---|
| Creates a hyperlink | href | |
| Inserts an image | src, alt, width, height | |
| Ordered (numbered) list | type | |
| Unordered (bulleted) list | type | |
| List item | value | |
| Line break | none |
, , , "]
D --> D1[" numbered list"]
D --> D2["
bulleted list"]
D --> D3["
with src and alt"]
F --> F1[" with href"]
HTML is the markup language used to create web pages. An HTML document has a head and a body, headings and paragraphs for text, ordered and unordered lists for items, and image and link tags that use attributes to describe their content. By writing tags correctly and saving the file with the .html extension, we can create web pages that any browser can display. These basics prepare us for creating more advanced pages, and the programming skills we learn in the next chapters build on this same careful, logical way of thinking.