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.
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:
Comments are generally used for one of three purposes.
HTML comments are enclosed in
-->. For example:
<!-- This is an HTML comment -->