HTML Tags, Elements, Attributes and Properties


ATTENTION: THIS PAGE IS Valid HTML 5 AND IS BEST VIEWED WITH HTML 5 - Please upgrade your browser or download one of the HTML 5 compatible browsers such as Mozilla Firefox, Chrome, Opera or IE 9 (March 14, 2011 or later). For more information see HTML 5 browsers.

If you find this helpful, please click the Google +1 Button to the left, if it is white, to make it turn blue or red. Thank you! (It also helps find this page again more easily.)

PDF mobile

Difference between tag and element in HTML

Definition of HTML tag and HTML element

(Some links on this page take you to details in the HTML Tag Reference. Bookmark this page in your Favorites so you can come back to it later.)

A tag in HTML is a representation of an element in the serialized form of an HTML document. A start tag or empty tag contains a <, the element name, one or more optional attribute name/value pairs separated from the element name and other attributes by whitespace and ends with either >, or with /> for a self-closing standalone tag such as <br/>, which is the break tag in HTML. An end tag contains just </, the tag name and >, for example </html> which is the </html> end tag.

An element is an object in the hierarchical model of a document. It always has an element name and may also have properties and/or child elements. The difference between an element and a tag is that an "element" is a more abstract representation of a node in the hierarchical structure of an HTML document that encompasses its attributes, child elements and other content such as text and CDATA sections. In an actual document, an element is explicitly represented by either a start tag and an end tag or closing tag enclosing its child elements and other content, if any, or simply by a standalone empty tag if it has no content. In some cases, an element is implied even when the corresponding tag does not appear in the document. A good example of this is the tbody element, which is often an implied element between a <table> tag and a <tr> table row tag.

Therefore, the term tag is normally used when referring to the mark up in the serialized form of an HTML document and the term element typically refers to the internal representation of an HTML object as a node in the document's hierarchical object model, encompassing all of its descendants.

Style of tags and elements on this site

In an HTML document's serialized form, the name of a tag can be easily recognized because it will always be preceded by a left angle bracket ("<"), if it's a start tag or a standalone tag, or the by the characters "</" if it's an end tag. On this site, an element name with these characters and an ending delimiter (">" or "/>") indicates that the serial representation of the element is being discussed. These delimiters will only be used when discussing HTML tags, since they are used to delimit HTML code from other text in the serialized form of HTML documents.

The term element refers to a node, along with any descendants, in the hierarchical object model of the abstract representation of an HTML document, used internally by an HTML parser. On this site, an element name without the angle bracket delimiters ("<", ">", "</" or "/>") indicates that the representation of the element in the abstract object model is being discussed.

Difference between attribute and property in HTML

Definition of HTML attribute and HTML property

The difference between an attribute and a property is analogous to the difference between a tag and an element.

An attribute in HTML is a named property associated with an element as coded in the serialized form of an HTML document. In a marked-up document, attribute name/value pairs can be coded in a start tag or a standalone tag between the element name and the tag's terminating > or /> delimiter separated from the element name and other attributes by whitespace. The code for an HTML attribute always consists of the attribute name, an equal sign (=) and the value of the property enclosed in quotes, even if the attribute is a boolean attribute.

A property is a named characteristic of something in the internal model of an HTML document. The value of the property may be set by an attribute in the serialized form of an element, inherited from a parent element in the hierarchical model of the document or set to some default value.

Valid HTML 5