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:
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.
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:
<tagname att1="value" att2="value">
Block elements are elements that separate a block of content. For example, a paragraph (
<p>) element is a block element. Other block elements include:
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:
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.
HTML comments are enclosed in
-->. For example:
<!-- This is an HTML comment -->