What is difference between HTML elements and tags ?
Printable View
What is difference between HTML elements and tags ?
Tags are labels you use to mark up the beginning and end of an element. The only difference between an opening tag and a closing tag is the forward slash "/". You label content by putting it between an opening tag and a closing tag. HTML is all about elements.
“Elements” and “tags” are terms that are widely confused. HTML documents contain tags, but do not contain the elements.
HTML tags vs. elements vs. attributes
HTML elements
An element in HTML represents some kind of structure or semantics and generally consists of a start tag, content, and an end tag. The following is a paragraph element:
<p>
This is the content of the paragraph element.
</p>
HTML tags
Tags are used to mark up the start and end of an HTML element.
<p></p>
HTML attributes
An attribute defines a property for an element, consists of an attribute/value pair, and appears within the element’s start tag. An element’s start tag may contain any number of space separated attribute/value pairs.
The most popular misuse of the term “tag” is referring to alt attributes as “alt tags”. There is no such thing in HTML. Alt is an attribute, not a tag.
Tags are used to mark up the start of an HTML element and they are usually enclosed in angle brackets. An example of a tag is: <h1>.
A HTML tag is like a container for either content or other HTML tags. A HTML element consists of the start tag + content tag + end tag. Some HTML tags do not have end tags like <img> hence in those cases HTML element will consist of start tag + content.