You are on page 1of 1

Overview[edit]

Syntax[edit]
Parts of an HTML container element

In the HTML syntax, most elements are written with a start tag and an end tag, with the content
in between. An HTML tag is composed of the name of the element, surrounded by angle
brackets. An end tag also has a slash after the opening angle bracket, to distinguish it from the
start tag. For example, a paragraph, which is represented by the  <p>  element, would be written
as:

<p>In the HTML syntax, most elements are written ...</p>

However, not all of these elements require the end tag, or even the start tag, to be present.
[5]
 Some elements, the so-called void elements, do not have an end tag. A typical example is
the  <br>  (hard line-break) element. A void element's behavior is predefined, and it cannot
contain any content or other elements. For example, an address would be written as:

<p>P. Sherman<br>42 Wallaby Way<br>Sydney</p>

When using XHTML, it is required to open and close all elements, including void elements. This
can be done by placing an end tag immediately after the start tag, but this is not legal in HTML 5
and will lead to two elements being created. An alternative way to specify that it is a void
element, which is compatible with both XHTML and HTML 5, is to put a  /  at the end of the tag
(not to be confused with the  /  at the beginning of a closing tag).

<p>P. Sherman<br />42 Wallaby Way<br />Sydney</p>

HTML attributes are specified inside the start tag. For example, the  <abbr>  element, which
represents an abbreviation, expects a  title  attribute within its opening tag. This would be
written as:

<abbr title="abbreviation">abbr.</abbr>

Informally, HTML elements are sometimes referred to as "tags" (an example of synecdoche),
though many prefer the term tag strictly in reference to the markup delimiting the start and end of
an element.
Element (and attribute) names may be written in any combination of upper or lower case in
HTML, but must be in lower case in XHTML. [9] The canonical form was upper-case until HTML 4,
and was used in HTML specifications, but in recent years, lower-case has become more
common.

You might also like