views:

26

answers:

1

What's the difference between the appendName() and appendHttpEquiv() methods of headMeta()? As an example, is keywords meant to be used with Name or http-equiv?

$view->headMeta()->appendHttpEquiv('keywords', 'keys');
or 
$view->headMeta()->appendName('keywords', 'keys');
+5  A: 

The difference is

$view->headMeta()->appendHttpEquiv('keywords', 'keys');

creates

<meta http-equiv="keywords" content="keys" >

while

$view->headMeta()->appendName('keywords', 'keys');

creates

<meta name="keywords" content="keys" >

According to the W3C specs

http-equiv may be used in place of the name attribute. HTTP servers use this attribute to gather information for HTTP response message headers.

The XHTML2.0 specs are a bit more descriptive on this:

HTTP-EQUIV binds the element to an HTTP header field. An HTTP server may use this information to process the document. In particular, it may include a header field in the responses to requests for this document: the header name is taken from the HTTP-EQUIV attribute value, and the header value is taken from the value of the CONTENT attribute. HTTP header names are not case sensitive.

NAME specifies the name of the name/value pair. If not present, HTTP-EQUIV gives the name.

Since you are unlikely sending the keywords in the header, using name is the proper way.

Gordon
Is there a reference somewhere to help me decide whether to use name or http-equiv for each attribute? I'm wondering about Content-Type, set-cookie, Cache-Control and more, so a reference list would definitely help.
jblue
@jblue [Wikipedia](http://en.wikipedia.org/wiki/Meta_element) lists [metatags.org](http://www.metatags.org/all_metatags)
Gordon