<meta/> Tag Syntax
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet ...?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> ... metadata content ... <meta http-equiv="..." content="..."/> ... metadata content ... <title>My Title</title> ... metadata content ... <meta name="..." content="..."/> ... metadata content ... </head> <body> ... flow content expected ... <meta itemprop="..." content="..."/> ... ... phrasing content expected ... <meta itemprop="..." content="..."/> ... </body> </html>
Rules for coding the HTML meta element
Make sure you understand the difference between a tag and element and are familiar with the definitions of namespace and other HTML terms.
<meta/> tag as metadata content
- Code any <meta> tags in the <head> section of the HTML document where metadata content is expected.
- Each meta element consists of a standalone <meta/> tag. The element name uses lower case letters and should be in the HTML namespace, which it will pick up automatically from the
xmlns
attribute on the <html> tag. - Code either a
name
attribute or anhttp-equiv
attribute, but not both. The value of the attribute, which is enclosed in double quotes, is the name of the metadata or directive. - Code the
content
attribute with the value for the named metadata or directive in double quotes. - Since the
<meta/>
tag is a void element, it should always be coded as a self-closing tag terminated with the delimiter string/>
.
<meta/> tag for microdata properties
- Code the <meta> tag in the <body> section of the HTML document where either flow content or phrasing content is expected.
- The meta element consists of a standalone <meta/> tag. The element name uses lower case letters and should be in the HTML namespace, which it will pick up automatically from the
xmlns
attribute on the <html> tag. - Inside the <meta> tag, include an
itemprop
attribute to indicate the meta element represents a microdata property. The value of the attribute, which is enclosed in double quotes, is the name or URL of the microdata property. - Inside the <meta> tag, code a
content
attribute with the value of the microdata property in double quotes. - Since the
<meta/>
tag is a void element, it should always be coded as a self-closing tag terminated with the delimiter string/>
.
<meta/> Content Model
Contents of the meta element
Content: Empty. All properties are coded using attributes.
Since the <meta/>
tag is a void element, it is not allowed to have any content, even HTML comments and therefore should always be coded as a self-closing standalone tag, ending with the delimiters />
rather than just >
(<meta .../>
).