What is the difference between HTML tags and elements?

user picture user · Jan 20, 2012 · Viewed 111.5k times · Source

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?

Answer

4m01 picture 4m01 · Jan 20, 2012

HTML tag is just opening or closing entity. For example:

<p> and </p> are called HTML tags

HTML 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 element