{"id":98,"date":"2018-01-15T07:00:00","date_gmt":"2018-01-15T14:00:00","guid":{"rendered":"https:\/\/coreassistance.com\/tips\/?p=98"},"modified":"2018-01-12T13:42:21","modified_gmt":"2018-01-12T20:42:21","slug":"set-a-character-set","status":"publish","type":"post","link":"https:\/\/coreassistance.com\/tips\/2018\/01\/15\/set-a-character-set\/","title":{"rendered":"Set a Character Set"},"content":{"rendered":"<p>It&#8217;s important to define a character set for your HTML pages.  The character set tells the web browser how the characters (letters, numbers, punctuation, etc.) are encoded, and doing so is a bigger deal than you might think.<\/p>\n<p>The most common character set issue is special characters (including emoji) and other content not showing up properly.  That&#8217;s annoying, but it gets worse.  An incorrect or missing character set can actually be a significant security issue that opens the door to cross-site scripting attacks.<\/p>\n<p>The good news is that defining a character set is easy.  You just need to add a single <code>&lt;meta&gt;<\/code> element with a <code>charset<\/code> attribute as the first thing in your page&#8217;s <code>&lt;head&gt;<\/code>, like this:<\/p>\n<pre><code>&lt;meta charset=\"UTF-8\"&gt;<\/code><\/pre>\n<p>There are a few things you need to pay attention to when setting your character set:<\/p>\n<ul>\n<li>The <code>UTF-8<\/code> character set is highly recommended for pretty much all use cases these days.<\/li>\n<li>Make sure the character set you define in your <code>&lt;meta&gt;<\/code> element matches the character encoding of the actual source files you&#8217;re using.  You can usually select the character encoding in the preferences of your text editor, or when saving your files.<\/li>\n<li>Make sure your character set <code>&lt;meta&gt;<\/code> element is the first thing in your <code>&lt;head&gt;<\/code>, as some web browsers will only look at the first 1024 bytes of a file before choosing a character encoding for the entire page.<\/li>\n<li>Note that if the web server serving your page sets a <code>Content-Type<\/code> header, the character set defined in that header will override your <code>&lt;meta&gt;<\/code> element (but that doesn&#8217;t mean you shouldn&#8217;t set one in your HTML anyway).<\/li>\n","protected":false},"excerpt":{"rendered":"<p>Avoid garbled content and security issues by adding a single element to your pages.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-98","post","type-post","status-publish","format-standard","hentry","category-htmlcss"],"_links":{"self":[{"href":"https:\/\/coreassistance.com\/tips\/wp-json\/wp\/v2\/posts\/98","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/coreassistance.com\/tips\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coreassistance.com\/tips\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coreassistance.com\/tips\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coreassistance.com\/tips\/wp-json\/wp\/v2\/comments?post=98"}],"version-history":[{"count":9,"href":"https:\/\/coreassistance.com\/tips\/wp-json\/wp\/v2\/posts\/98\/revisions"}],"predecessor-version":[{"id":158,"href":"https:\/\/coreassistance.com\/tips\/wp-json\/wp\/v2\/posts\/98\/revisions\/158"}],"wp:attachment":[{"href":"https:\/\/coreassistance.com\/tips\/wp-json\/wp\/v2\/media?parent=98"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coreassistance.com\/tips\/wp-json\/wp\/v2\/categories?post=98"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coreassistance.com\/tips\/wp-json\/wp\/v2\/tags?post=98"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}