HTML Basic

Basic HTML examples showing a minimal document structure, headings, paragraphs, links, and images.

On this page

HTML Basic

Basic HTML examples showing a minimal document structure, headings, paragraphs, links, and images.

This page shows a few basic HTML examples to illustrate the structure of a simple web page. Some tags are explained in later sections.


HTML Document Structure

An HTML document starts with a document type declaration and is wrapped by the html element. The visible content is placed inside the body.


<!DOCTYPE html>

<html>

 <head>

  <title>Page Title</title>

 </head>

 <body>


  <h1>My First Heading</h1>

  <p>My first paragraph.</p>


 </body>

</html>


The DOCTYPE Declaration

The doctype declaration tells the browser which version of HTML the page uses. It must appear once, at the very top of the document.


<!DOCTYPE html>


The HTML5 doctype is simple and not case-sensitive.


Headings

Headings define titles and section headings. HTML provides six levels, from h1 (most important) to h6 (least important).


<h1>Main Title</h1>

<h2>Section Title</h2>

<h3>Subsection Title</h3>


Paragraphs

Paragraphs are used for blocks of text and are defined with the p tag.


<p>This is a paragraph.</p>

<p>This is another paragraph.</p>


Links

Links are created with the a tag. The destination is set using the href attribute.


<a href="https://example.com">Visit example.com</a>


Images

Images are embedded using the img tag. Common attributes include src, alt, width, and height.


<img src="logo.png" alt="Site logo">


Viewing HTML Source

You can inspect how a web page is built by viewing its source or using browser developer tools.


View page source:

- Windows / Linux: Ctrl + U

- macOS: Cmd + Option + U


Inspect an element:

- Right-click an element and choose "Inspect"


HTML Basic Examples (7)