tags:

views:

73

answers:

2

Should I write the meta-tags in utf-8 format?

For example, is it okay to have double-quotes in the meta-keywords like this:

 19" wheels

or special characters like the & sign... ?

Thanks

NOTE: Im using utf-8 encoding on all my pages!

A: 

The character set depends on what set you are encoding the whole page in.

As to quotes and other special characters, you need to escape them using character references:

"

As to really special characters like 国, they should be o.k. to use as long as the page uses appropriate encoding (i.e. utf-8).

Pekka
Im using utf-8 on all my pages... Does it matter if I use the html entities or whatever it's called?
Camran
For quotes, ampersands and other control characters you should definitely use the encoded versions.
Pekka
A: 

Should I write the meta-tags in utf-8 format?

You should use a consistent encoding throughout.

For example, is it okay to have double-quotes in the meta-keywords

As with all attribute values, you can't use the character you delimit the attribute value with in the value without representing it with an entity.

<meta name="length" content="19""> <!-- This is an error -->
<meta name="length" content='19"'> <!-- This is fine -->
<meta name="length" content='19&quot;'> <!-- This is fine -->
<meta name="length" content="19&quot;"> <!-- This is fine -->
<meta name="length" content="19″"> <!-- Using the double prime character is also fine.
                                        It is distinct from the double quotes used to 
                                        delimit the attribute value.
                                        Technically, it is the best option as it is the
                                        correct character to represent an inch.
                                     -->

or special characters like the & sign... ?

There are times when you can use a raw ampersand in HTML data, but they are infrequent and it is easier to always use &amp; then it is to try to remember the exceptions.

David Dorward