99 of 133 menu

Meta tag

The meta tag specifies some service commands to the browser or search engines: page encoding, page description for search engines, page author, and so on.

The principle of the tag is as follows (with some exceptions): the command name is specified (in the name attribute or in the http-equiv attribute), and the command value is specified in the content attribute. In essence, this tag contains a group of tags (commands), the general name of which is meta-tags

The meta tag does not require a closing tag.

The meta tag should be used inside the head tag.

Popular usage examples

Document encoding

Currently, the encoding standard is utf-8. Theoretically, you don't have to specify the encoding explicitly (via the meta tag) - the browser should understand you. In practice, I wouldn't recommend doing this - the encoding may get confused and instead of Russian text you'll see gibberish.

In HTML5, encoding is specified in a simplified form:

<meta charset="utf-8">

Previously, the encoding was set like this (it is not worth doing this now, it is outdated, you can find it in outdated textbooks):

<meta http-equiv="content-type" content="text/html; charset=utf-8">

Document Description

The meta description of the document is intended for search engines, it should contain a short description of the page. From this description, under certain conditions, the search engine can make snippet of the site page. Snippet is a short description of the site page during search. Accordingly, the meta description of the page should be made the way you want the page snippet to appear in the search and for each page of the site its own.

It should be used like this:

<meta name="description" content="This page talks about meta tags.">

Document keywords

Meta keywords are meant for search engines to indicate the most important words that will be used to search for a page. Currently, due to abuse by webmasters, search engines do not attach importance to this meta tag.

It should be used like this (keywords and phrases are listed separated by commas):

<meta name="keywords" content="Meta tag, Meta description, HTML redirect" >

Redirect (transfer to another page)

You can make it so that when you go to a certain page, the user is automatically transferred to another (for example, if the page has moved). Use it like this (5 is the number of seconds after which the transfer will occur):

<meta http-equiv="refresh" content="5; url=http://www.example.com/">

Possible attributes

Attribute Description
name Meta tag name. The value of a meta tag with this name is specified by the content attribute.
http-equiv Allows you to set HTTP headers to send to the browser. Specifies the header name. The header value is specified by the content attribute.
content Sets the value of the attribute specified by the name or http-equiv attribute.
charset Specifies the encoding of the document. The current standard is utf-8.
byenru