Skip to main content

Anatomy of html tags

We create elements of the page with tags. Html tags are enclosed in angle brackets < > and contain lowercase letters. Most html tags have an opening < > and a closing </ >tag.

THe example below includes a paragraph <p> </p> and a level-one heading <h1> </h1>.

index.html
<p>This is a paragraph.</p>
<h1>This is a heading</h1>

Attributes

Tags may include attributes. Attributes follow the syntax:

attribute="value"
index.html
<p>This is a paragraph.</p>
<h1>This is a heading</h1>
<a href="http://www.google.com">lookup</a>
<img src="mycat.jpg" alt="Rocky the beast">

Some tags have required attributes, such as the landing address of a link as in line 3 where the href attribute is required. The src and alt attributes of an img tag are also required. Whether required or optional, attributes follow the same syntax.

singleton tags

Some tags are singleton tags. Singleton tags have no closing tag.

index.html
<img src="mycat.jpg" alt="Rocky the beast">
<br>
<hr>

Some tags have no corresponding </ >. Image <img> tags, line breaks <br> and horizontal rule tags <hr> are three common examples of single tags.