HTML Elements

Contact Us or call 1-877-932-8228
HTML Elements

HTML elements describe the structure and content of a Web page. Tags are used to indicate the beginning and end of elements. The syntax is as follows:

<tagname>Element content</tagname>


Tags often have attributes for further defining the element. Attributes come in name-value pairs.

In HTML (without the X) some tags have attributes that don't take a value, like so:

<tagname att1>Element content</tagname>

Note that attributes only appear in the open tag, like so:

<tagname att1="value" att2="value">Element content</tagname>

The order of attributes is not important.

Empty vs. Container Tags

The tags shown above are called container tags because they have both an open and close tag with content contained between them. Tags that do not contain content are called empty tags. The syntax is as follows:




Blocks and Inline Elements

Block-level Elements

Block elements are elements that separate a block of content. For example, a paragraph (<p>) element is a block element. Other block elements include:

  • Lists (<ul> and <ol>)
  • Tables (<table>)
  • Forms (<form>)
  • Divs (<div>)

Inline Elements

Inline elements are elements that affect only snippets of content and do not block off a section of a page. Examples of inline elements include:

  • Links (<a>)
  • Images (<img>)
  • Formatting tags (<b>, <i>, <tt>, etc.)
  • Phrase elements (<em>, <strong>, <code>, etc.)
  • Spans (<span>)

Important: many formatting tags have been deprecated in HTML 4.0 and XHTML 1.0. Although the ones listed here are not deprecated, their use is discouraged as the same effect can be accomplished with CSS.


Comments are generally used for one of three purposes.

  1. To write helpful notes about the code; for example, why something is written in a specific way.
  2. To comment out some code that is not currently needed, but may be used sometime in the future.
  3. To debug a page.

HTML comments are enclosed in <!-- and -->. For example:

<!-- This is an HTML comment -->