HTML Examples

An example of how a simple document writen in HTML would look

<html>
<body>
The content of the body element is displayed in your browser.
</body>
</html>


Here is an example of formatting paragraphs in HTML

<html>
<body>

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

<p>Paragraph elements are defined by the p tag.</p>

</body>
</html>

Would produce this.

This is a paragraph.

This is a paragraph.

This is a paragraph.

Paragraph elements are defined by the p tag.


Headers would be done like this.

<html>
<body>

<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
<h4>This is heading 4</h4>
<h5>This is heading 5</h5>
<h6>This is heading 6</h6>

<p>Use heading tags only for headings. Don't use them just to make something bold. Use other tags for that.</p>

</body>
</html>

Would produce this.

This is heading 1

This is heading 2

This is heading 3

This is heading 4

This is heading 5
This is heading 6

Use heading tags only for headings. Don't use them just to make something bold. Use other tags for that.


Centering Headers

<html>
<body>

<h1 align="center">This is heading 1</h1>

<p>The heading above is aligned to the center of this page. The heading above is aligned to the center of this page. The heading above is aligned to the center of this page.</p>

</body>
</html>

Gives

This is heading 1

The heading above is aligned to the center of this page. The heading above is aligned to the center of this page. The heading above is aligned to the center of this page.


Horizontal Rule.

<html>
<body>
<p>The hr tag defines a horizontal rule:</p>
<hr>
<p>This is a paragraph</p>
<hr>
<p>This is a paragraph</p>
<hr>
<p>This is a paragraph</p>
</body>
</html>

The hr tag defines a horizontal rule:


This is a paragraph


This is a paragraph


This is a paragraph


Text Formatting

<html>
<body>

<b>This text is bold</b>

<br>

<strong>
This text is strong
</strong>

<br>

<big>
This text is big
</big>

<br>

<em>
This text is emphasized
</em>

<br>

<i>
This text is italic
</i>

<br>

<small>
This text is small
</small>

<br>

This text contains
<sub>
subscript
</sub>

<br>

This text contains
<sup>
superscript
</sup>

</body>
</html>

Gets

This text is bold
This text is strong
This text is big
This text is emphasized
This text is italic
This text is small
This text contains subscript
This text contains superscript