A lot of developers use the terms HTML tags and HTML elements interchangeably, but are they the same?
Tags are used to define HTML elements. We do that by marking (wrapping) content with opening and closing HTML tag names that match the type of content we’re working with. E.g.
An HTML Element is the result of content + HTML tags.
The following is not a paragraph element:
I’m just a piece of a text content right now..
This is a paragraph element:
<p>Now I’m a paragraph element! Hurray for me!</p>
This is not a paragraph element:
That’s an opening/start paragraph tag. It would be technically wrong to call it an element because it’s missing two key ingredients, content, and a closing (
It’s not a huge problem if you refer to HTML elements as tags or vice versa. What really matters is that you know the difference, if anything for the sake of not getting embarrassed at a job interview, where they could ask you this type of question.