Tag vs Element

An element is not a tag, and a tag is not an element. 

The Difference?

In most cases, an element is made up by an opening, and closing tag. For example, below we have a div tag:


Below, we have a fully created div element:


Now, that’s pretty straightforward, but as I’m guessing you’re thinking - there are some things which have no closing tag such as break, image or horizontal rule. 

In the times of XHTML (which is still kicking around), these would self close, by placing a forward slash before the last right angle bracket.

These would still be referred to as elements instead of tags


While I’m on the the topic of HTML naming, I thought I’d touch on attributes. These are what you name the items that sit within the opening tag of the element. So this might include things like: 

  • width
  • height
  • alt
  • title
  • rel
  • src
  • href

To name just a few. They are not called the alt tag, or anything-tag. They are attributes. Plain & simple.

117 notes

  1. michaelw90 posted this