{"id":58,"date":"2006-02-06T00:32:24","date_gmt":"2006-02-06T05:32:24","guid":{"rendered":"http:\/\/www.killersites.com\/blog\/?p=58"},"modified":"2017-02-23T10:10:57","modified_gmt":"2017-02-23T15:10:57","slug":"going-beyond-web-standards","status":"publish","type":"post","link":"https:\/\/www.killersites.com\/blog\/2006\/going-beyond-web-standards\/","title":{"rendered":"When breaking from the Web standards makes sense."},"content":{"rendered":"<p><strong><img loading=\"lazy\" decoding=\"async\" width=\"81\" vspace=\"5\" hspace=\"5\" height=\"72\" border=\"0\" src=\"http:\/\/www.killersites.com\/UserFiles\/Image\/headShot_blog_small.jpg\" alt=\"\" \/><\/strong><\/p>\n<p><strong>INTRODUCTION<\/strong><\/p>\n<p>Following the Web Standards makes perfect sense when it allows you to build easy to mantain websites that work with the major browsers. It doesn&#8217;t make sense when using Web Standards forces you to use hacks, prevents you from taking advantage of a great technology\/feature&nbsp;or makes your job as a web designer or developer more difficult.<\/p>\n<p>Let&#8217;s take a look at 3 very useful technologies that are not in the Web Standards, but&nbsp;do not have any of the negative consequences associated with browser specific code:<\/p>\n<ol>\n<li><strong>IE conditional comments:<\/strong> for cross-browser CSS layouts. <\/li>\n<li><strong>AJAX &#8211; using the XMLHTTPobject:<\/strong> for behind the scenes browser to server communication. <\/li>\n<li><strong>The innerHTML property:<\/strong> &nbsp;for quick and easy DOM manipulation. <\/li>\n<\/ol>\n<p>Though each of the above are not part of the Web Standards, they provide terrifically useful functionality without any hangups.<\/p>\n<p><strong>IE CONDITIONAL COMMENTS<\/strong><\/p>\n<p>Though IE conditional comments only work in IE, it makes great sense to use them when&nbsp;you want to isolate code. Since all other browsers will see IE conditional comments as being only HTML comments, there can never be a down side to IE conditional comments. It is the proper way of dealing with IE 6&#8217;s problems with CSS code.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<p>&lt;head&gt;<\/p>\n<p>&lt;link href=&quot;standardStyle.css&quot; rel=&quot;stylesheet&quot; type=&quot;text\/css&quot; media=screen&gt;<\/p>\n<p>&lt;!&#8211;[if IE 6]&gt;<br \/>&lt;link href=&quot;ie_style.css&quot; rel=&quot;stylesheet&quot; type=&quot;text\/css&quot; media=screen&gt;<br \/>&lt;![endif]&#8211;&gt;<\/p>\n<p>&lt;\/head&gt;<\/p>\n<p>In the above example, we use IE conditional comments to hide IE specific CSS from all other browsers.&nbsp;Spefically, the IE conditional comments:<\/p>\n<p>&nbsp;(&lt;!&#8211;[if IE 6]&gt; and &lt;![endif]&#8211;&gt;)&nbsp;<\/p>\n<p>is loading the &#8216;ie_style.css&#8217; style sheet only if the browser reading the page is IE6. <\/p>\n<p>IE&nbsp;conditional comments are a replacement for dangerous CSS hacks that are commonly used to deal with IE&#8217;s occasional problems with standard CSS.<\/p>\n<p><strong>AJAX<\/strong><\/p>\n<p>The heart of AJAX is in the XMLHTTPObject &#8211; a JavaScript function built into every major browser but is NOT part of the Web Standards. Given how powerful&nbsp;AJAX is, and given how popular it has become, you can be sure that every major browser will continue to support it. <\/p>\n<p>So as a Web Standards zealot, you have to ask yourself whether blind adhereance to the Web standards is worth missing out on this important tool? That is to say, if you&#8217;re a web standards zealot, you couldn&#8217;t\/shouldn&#8217;t use AJAX since it is not part of the official Web standards &#8230; it&#8217;s your choice.&nbsp;<\/p>\n<p><strong>&nbsp;INNER HTML PROPERTY<\/strong><\/p>\n<p>InnerHTML is an easy to use&nbsp;property supported by all the major browsers that allows you to dynamically update\/change web pages without having to do a page refresh. <\/p>\n<p><strong>Example using innerHTML:<\/strong><\/p>\n<p>var targetDiv = document.getElementById(&quot;targetDiv&quot;); <br \/>targetDiv.innerHTML = &quot;&lt;p&gt;innerHTML is fast and easy!&lt;\/p&gt;&quot;<\/p>\n<p><strong>Example using DOM methods:<\/strong><\/p>\n<p>var para = document.createElement(&quot;p&quot;);<br \/>var targetDiv = document.getElementById(&quot;targetDiv&quot;); <br \/>targetDiv.appendChild(para);<br \/>var txt = document.createTextNode(&quot;Dom methods are much longer than innerHTML&quot;);<br \/>para.appendChild(txt);<\/p>\n<p>As you can see with the above examples, to insert text with DOM methods takes a lot more code than innerHTML. So, should you use innerHTML?<\/p>\n<p><strong>The answer:<\/strong> Browser makers typically don&#8217;t remove functionality, and given that innerHTML is supported by all the browsers and is easy to use, this is yet another example where I will break from the standards and feel comfortable about it.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>3 examples of when going beyond the Web Standards makes sense.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.killersites.com\/blog\/wp-json\/wp\/v2\/posts\/58"}],"collection":[{"href":"https:\/\/www.killersites.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.killersites.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.killersites.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.killersites.com\/blog\/wp-json\/wp\/v2\/comments?post=58"}],"version-history":[{"count":2,"href":"https:\/\/www.killersites.com\/blog\/wp-json\/wp\/v2\/posts\/58\/revisions"}],"predecessor-version":[{"id":4820,"href":"https:\/\/www.killersites.com\/blog\/wp-json\/wp\/v2\/posts\/58\/revisions\/4820"}],"wp:attachment":[{"href":"https:\/\/www.killersites.com\/blog\/wp-json\/wp\/v2\/media?parent=58"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.killersites.com\/blog\/wp-json\/wp\/v2\/categories?post=58"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.killersites.com\/blog\/wp-json\/wp\/v2\/tags?post=58"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}