HTML describes the content and structure of a web page. Before adding colours or layouts, learn the document skeleton, elements, tags and attributes that browsers use to understand your content.
HTML stands for HyperText Markup Language. It is a markup language, not a programming language. You use elements to identify headings, paragraphs, navigation, images, forms and other content. The browser reads the markup and builds the document structure.
Most elements have an opening tag, content and a closing tag. For example, <p>Hello</p> creates a paragraph. Some elements, such as <img> and <br>, are void elements and do not wrap content.
<!DOCTYPE html> tells the browser to use modern HTML parsing. The <html> element contains the document. The <head> holds information about the page, while <body> contains what visitors see.
The <title> element sets the browser-tab title. The lang attribute on the root element identifies the page language and helps assistive technology and search systems interpret the content.
Tags describe the element type; attributes provide extra information. In <html lang="en">, lang is an attribute and en is its value. Attribute values should be quoted.
Nest elements in the correct order. Close inner elements before outer elements. Clean nesting makes your document easier to maintain and reduces browser rendering surprises.
<!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>Hello, world!</h1>
<p>This is my first HTML page.</p>
</body>
</html>
<h1>Department of Computer Science</h1>
<p>Welcome to the department website.</p>
<p>HTML gives each piece of content a clear role.</p>
Create a valid HTML document with a page title, one main heading, two paragraphs and a language attribute on the html element.
<!DOCTYPE html> <html lang="en"> <head> <title>About Me</title> </head> <body> <h1>About Me</h1> <p>First paragraph.</p> <p>Second paragraph.</p> </body> </html>