References

Beginner-friendly references for web development, with live, editable examples.

The HTML name attribute

Attribute All modern browsers Updated
Quick answer

The HTML name attribute names a piece of document metadata, whose value is given by the accompanying content attribute. It is used on the <meta> element.

Overview

The name attribute names a piece of document metadata, whose value is given by the accompanying content attribute. It applies to the <meta> element.

The most important values for SEO and mobile are name="description" (search snippet), name="viewport" (responsive layout) and name="robots" (indexing rules). The value itself goes in the content attribute.

Syntax

<meta name="description" content="A short summary of the page.">

Values

Value
description | viewport | robots | keywords | author | theme-color | referrer | color-scheme | generator

Best practices

  • Declare the character encoding with <meta charset="utf-8"> first in the <head>.
  • Load scripts with defer (or as modules) so they do not block parsing.
  • Protect third-party resources with integrity and crossorigin (Subresource Integrity).
  • Use resource hints like preload deliberately, paired with the right as value.

Frequently asked questions

What does the name attribute do?
Names a metadata value on a meta tag.
Where do head attributes apply?
On the metadata elements in the <head><meta>, <link>, <script> and <base>.
What is the difference between async and defer?
async runs a script as soon as it loads in no set order; defer runs scripts in order after the document is parsed.
Which elements use the name attribute?
It is an element-specific attribute, used on document head elements like <meta>, <link> and <script>.