Content deleted Content added
Sapphaline (talk | contribs) →Overview: <p> doesn't need an end tag Tag: Reverted |
Reverted 1 edit by Sapphaline (talk): <p> does need an end tag |
||
Line 91:
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 bracket]]s. 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 {{tag|p|o}} element, would be written as:
<syntaxhighlight lang="html">
<p>In the HTML syntax, most elements are written ...</p>
</syntaxhighlight>
However, not all of these elements {{em|require}} the end tag, or even the start tag, to be present.<ref name=whatwg-syntax-tag-omission/> <!--Examples will be given throughout the article when I get around to it. —Ms2ger--> Some elements, the so-called ''[[#Void elements|void elements]]'', do not have an end tag. A typical example is the {{tag|br|o}} (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:
<syntaxhighlight lang="html">
<p>P. Sherman<br>42 Wallaby Way<br>Sydney</p>
</syntaxhighlight>
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 <code>/</code> at the {{em|end}} of the tag (not to be confused with the <code>/</code> at the {{em|beginning}} of a closing tag).
|