I notice that most people use the words HTML tags and HTML elements interchangeably.
But what is the difference between them?
The way I see it is that tags are in the source code and elements are processed tags (by the browser) in the DOM. Am I wrong?
lets put this in a simple term. An element is a set of opening and closing tags in use.
In this part
<p>
is a tag.in this part
<blockquote>
is an element.http://html.net/tutorials/html/lesson3.php
For example:
Where as elements are something that consists of start tag and end tag as shown:
HTML tag is just opening or closing entity. For example:
<p>
and</p>
are called HTML tagsHTML element encompasses opening tag, closing tag, content (optional for content-less tags) Eg:
<p>This is the content</p>
: This complete thing is called a HTML elementTags and Elements are not the same.
Elements
They are the pieces themselves, i.e. a paragraph is an element, or a header is an element, even the body is an element. Most elements can contain other elements, as the body element would contain header elements, paragraph elements, in fact pretty much all of the visible elements of the DOM.
Eg:
Tags
Tags are not the elements themselves, rather they're the bits of text you use to tell the computer where an element begins and ends. When you 'mark up' a document, you generally don't want those extra notes that are not really part of the text to be presented to the reader. HTML borrows a technique from another language, SGML, to provide an easy way for a computer to determine which parts are "MarkUp" and which parts are the content. By using '<' and '>' as a kind of parentheses, HTML can indicate the beginning and end of a tag, i.e. the presence of '<' tells the browser 'this next bit is markup, pay attention'.
The browser sees the letters '
' and decides 'A new paragraph is starting, I'd better start a new line and maybe indent it'. Then when it sees '
' it knows that the paragraph it was working on is finished, so it should break the line there before going on to whatever is next.- Opening tag.
- Closing tagHTML Elements
An HTML element usually consists of a start tag and end tag, with the content inserted in between:
The HTML element is everything from the start tag to the end tag. Source
HTML Attributes
An attribute is used to define the characteristics of an HTML element and is placed inside the element's opening tag. All attributes are made up of two parts: a name and a value.
HTML Tag vs Element
"Elements" and "tags" are terms that are widely confused. HTML documents contain tags, but do not contain the elements. The elements are only generated after the parsing step, from these tags. Source: wikipedia > HTML_element
An HTML element is defined by a starting tag. If the element contains other content, it ends with a closing tag.
For example
<p>
is starting tag of a paragraph and</p>
is closing tag of the same paragraph but<p>This is paragraph</p>
is a paragraph element.Source:tutorialspoint > html_elements