= HTML tag
{c}
An <HTML tag> is a piece of source syntax that identifies the start or end of an <HTML element>. A start tag can contain <HTML attributes>; an end tag identifies a closing point under the parser's rules. The tag is source notation, while the resulting element is an object in the <Document Object Model>.<HTML Standard by WHATWG>[The HTML syntax, Tags and Attributes]{ref}
For example, `<p class="note">Hello</p>` contains a paragraph start tag, text content and a paragraph end tag. Parsing it produces one paragraph element, not two elements corresponding to the two tags. Its text is represented separately in a <DOM text node>.
An <HTML void element> such as `br` has no end tag in HTML syntax. Some other elements permit tags to be omitted in specified contexts, so counting start/end pairs is not a complete account of the parsed structure. A trailing slash is also governed by HTML's own rules; it does not generally turn an ordinary HTML element into a self-closing XML-style element.<HTML Standard by WHATWG>[Elements, void elements, optional tags and start-tag syntax]{ref}
Source context matters. Escaping `<` as `<` can make a tag-shaped example become displayed text instead of active markup. Programs explaining or transforming documents therefore need to distinguish the source syntax they are reading from the document structure that a parser constructs from it.
Back to article page