Search code examples
htmltagsmetadatameta

Meta tag: do I use name or id?


I saw that in HTML5, you don't use the name attribute, but use the id attribute, instead. I also saw that you write metadata with the name attribute. So which one of them should I use while writing metadata?

<meta name="" content="">  

OR

<meta id="" content="">` 

Solution

  • you don't use the name attribute, but use the id attribute

    This only applies to a elements (whose name attribute is deprecated in favor of giving the closest element a corresponding ID). It doesn't apply to any other element with a name attribute, neither input, nor meta. In other words, you cannot replace the name attribute with an ID for any other element. Anyone suggesting otherwise is wrong.