HTML Basic Examples

Do not worry if these examples given below uses tags you have not learned yet.

You will be learning about them in the forthcoming chapters.

HTML Documents


All HTML documents must always be starting with a document type declaration: <!DOCTYPE html>.

The HTML document itself always begins with <html> and ends with </html>.

The visible part of the HTML document in the browser is between <body> and </body>.


<!DOCTYPE html>

<h1>My First Heading</h1>
<p>My first paragraph.</p>

Try it Yourself

HTML Headings


HTML headings are always defined using the <h1> to <h6> tags.

<h1> is the tag that defines the most important heading. <h6> is the tag that defines the least important heading: 


<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
Try it Yourself

HTML Paragraphs


HTML paragraphs are usually defined by using the <p> tag:


<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
Try it Yourself

HTML Links


HTML links are defined by using the <a> tag:


<a href="http://daks.me">This is a link</a>
Try it Yourself

The link's destination is always mentioned or specified in the href attribute

Attributes are necessary for providing additional information about the HTML elements.

HTML Images


HTML images are mentioned with the <img> tag.

The source file (src), alternative text (alt), and size (width and height) are given as attributes:


<img src="/images/ngo.jpg" alt="ngo.com" width="104" height="142">
Try it Yourself