The Difference Between a Tag and an Element
A Tag
A tag is simply a less than sign (<
), followed by a forward slash (/
) if it’s a closing/ending tag, followed by a string of one or more pre-defined characters (a
, li
, body
, etc), followed by a greater than sign (>
). For example, the starting/opening body tag:
<body>
Or the closing paragraph tag:
</p>
If you make a mistake in the spelling of a tag, that is, if you spell a tag that is not defined by HTML, then browsers will typically ignore it. If your misspelled tags contain content, the tags are ignored, but the content is rendered in a browser. The content “Here’s my misshapen document” in the following example will be rendered in the browser, but the tags will be ignored.
<boddyy> Here’s my misshapen document </boddyy>
An Element
An element consists of the opening/starting tag, all its allowable content, and the closing/ending tag. If it’s an empty element, like, for example, the image tag, then the element consists of only the opening/starting tag. Here’s the image element:
<img src="shihtzu.jpg" width="300" height="300" alt="[A 5-year old Shih Tzu]">
And here’s the paragraph element:
<p>This is a paragraph.</p>