<?xml version="1.0" encoding="utf-8"?>

<feed xmlns="http://www.w3.org/2005/Atom">

    <title></title>
    <link href="http://hughesblog.co.uk/" />
    <link href="http://hughesblog.co.uk/atom.xml" rel="self" />
    <updated>2013-04-05T21:26:47+01:00</updated>
    <id>http://hughesblog.co.uk/</id>
    <author>
        <name></name>
    </author>


    <entry>
        <title>Goodbye WebKit</title>
        <link href="http://hughesblog.co.uk/2013/04/goodbye-webkit/" />
        <id>http://hughesblog.co.uk/2013/04/goodbye-webkit/</id>
        <published>2013-04-05T00:00:00+01:00</published>
        <updated>2013-04-05T00:00:00+01:00</updated>
        <author>
            <name></name>
        </author>

        <summary>When Opera announced their move to WebKit, I wanted to write about the poorer place the web would be without the Presto rendering engine. And then Google announced Blink and suddenly I am faced with another browser testing headache.</summary>

        <content type="html">&lt;p&gt;When Opera announced their move to WebKit, I wanted to write about the loss of competition, the growing WebKit monoculture, and the poorer place the web would be without the Presto rendering engine. And then Google announced &lt;a href=&quot;http://blog.chromium.org/2013/04/blink-rendering-engine-for-chromium.html&quot;&gt;Blink&lt;/a&gt; and everything changed again.&lt;/p&gt;

&lt;p&gt;Personally, I think Blink is a good thing. More browsers and more rendering engines means more competition and innovation. Remember the long years of IE6? That’s what a monoculture looks like. And because Blink is a fork of WebKit, it will already have solid support for standards and developers don’t need to worry about a sudden change in the next version of Chrome.&lt;/p&gt;

&lt;p&gt;Another reason to be optimistic is that Google seem to be committed to an &lt;a href=&quot;http://www.chromium.org/blink&quot;&gt;open development process&lt;/a&gt;. Thanks to Chrome, Blink will inherit an enormous number of users and Google are aware of their dominance in a space that relies on cooperation and interoperability. So far, they appear to be taking their responsibility to the wider web seriously.&lt;/p&gt;

&lt;p&gt;As I said, I think Blink is going to be good for the web. However, it does present some of us developers with a new browser testing headache. I &lt;em&gt;know&lt;/em&gt; I am supposed to test in all the browsers and I &lt;em&gt;know&lt;/em&gt; that you cannot assume that two WebKit browsers will work exactly the same. But I cannot test in Safari because I haven’t got a Mac.&lt;/p&gt;

&lt;p&gt;I &lt;em&gt;want&lt;/em&gt; to test my sites in Safari, but there is no way I can afford a Mac just for browser testing. And Windows remains dominant on the desktop, so it still makes sense to focus my testing there than on any other platform. With Chrome and Opera moving to Blink, there is no mainstream WebKit browser on Windows and as the two rendering engines diverge, this is going to become a problem. A headache for me, but something worse for Safari? Suddenly, and unexpectedly, WebKit is no longer the dominant force on the web.&lt;/p&gt;
</content>
    </entry>

    <entry>
        <title>Jekyll</title>
        <link href="http://hughesblog.co.uk/2012/11/jekyll/" />
        <id>http://hughesblog.co.uk/2012/11/jekyll/</id>
        <published>2012-11-26T00:00:00+00:00</published>
        <updated>2012-11-26T00:00:00+00:00</updated>
        <author>
            <name></name>
        </author>

        <summary>I have started using Jekyll, a minimalist static site generator, to manage my website. It might not be for everyone, but it might be a good choice if you feel like updating your site with a text editor and some command line magic.</summary>

        <content type="html">&lt;p&gt;I built the first version of this website using WordPress and, because nobody was there to stop me, I used everything. It had a dynamic sidebar, categories, comments, search, and various archives. I learned a lot about WordPress, but after a while I realised it was a lot more than I needed for posting the occasional bit of text.&lt;/p&gt;

&lt;p&gt;I looked a various content management systems, many of them claiming to be simple and elegant, but I was never convinced they offered any real advantages over the system I had already &lt;a href=&quot;https://github.com/johnkhughes/zero&quot;&gt;mastered&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Then I discovered &lt;a href=&quot;http://jekyllrb.com/&quot;&gt;Jekyll&lt;/a&gt;, a powerful, minimalist static site generator written in Ruby. Articles and pages are just plain text files; there is no default template or structure; and it supports all sorts of useful blogging features, like categories, tags, pagination, and archives.&lt;/p&gt;

&lt;p&gt;The sheer simplicity of the system appealed to the hacker in me, but there are also other benefits to having a static site.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;There is no database and no server-side scripting, so a static site loads &lt;em&gt;fast&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Hosting requirements are minimal. You can even host a Jekyll site using &lt;a href=&quot;http://pages.github.com/&quot;&gt;GitHub Pages&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Flat files are hard to hack, so your site is as secure as it could be.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;So Jekyll does what I want for my site right now. It certainly isn’t for everyone, or even for me all the time. I still like WordPress a lot and a good CMS is still the obvious choice for anyone who doesn’t want to spend their time staring at the command line. And if you need comments, multiple users, search, or just the ability to log in and edit the site from anywhere, you still need a CMS.&lt;/p&gt;
</content>
    </entry>

    <entry>
        <title>The q element</title>
        <link href="http://hughesblog.co.uk/2012/11/the-q-element/" />
        <id>http://hughesblog.co.uk/2012/11/the-q-element/</id>
        <published>2012-11-21T00:00:00+00:00</published>
        <updated>2012-11-21T00:00:00+00:00</updated>
        <author>
            <name></name>
        </author>

        <summary>The q element first turned up in HTML4 for inline quotations. Lack of support is not the problem it used to be, but I think there are still good reasons to avoid using this element.</summary>

        <content type="html">&lt;p&gt;The &lt;code&gt;&amp;lt;q&amp;gt;&lt;/code&gt; element first turned up in HTML4 for inline quotations and is still a part of HTML5. The idea is that the browser adds the correct quotation marks around the text, taking into account the current language and whether the text is nested inside another quotation. However, &lt;a href=&quot;http://www.alistapart.com/articles/qtag/&quot;&gt;lack of support&lt;/a&gt; meant that it was largely ignored. By the time support was added to Internet Explorer 8 more than eleven years after the &lt;code&gt;&amp;lt;q&amp;gt;&lt;/code&gt; element was standardised, most developers had forgotten about it.&lt;/p&gt;

&lt;p&gt;These days, all the major browsers support the element and the related &lt;code&gt;quotes&lt;/code&gt; CSS property. Despite this, I still don’t think it is a good idea to use the &lt;code&gt;&amp;lt;q&amp;gt;&lt;/code&gt; element. Take a look at the following extract from &lt;a href=&quot;http://www.gutenberg.org/ebooks/2097&quot;&gt;The Sign of the Four&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;He laughed until his ears were quite red. “That would hardly do,” he cried. “I don’t know what he would say if I brought you in that sudden way. No, I must prepare you by showing you how we all stand to each other. In the first place, I must tell you that there are several points in the story of which I am myself ignorant. I can only lay the facts before you as far as I know them myself.&lt;/p&gt;

&lt;p&gt;“My father was, as you may have guessed, Major John Sholto, once of the Indian army. He retired some eleven years ago, and came to live at Pondicherry Lodge in Upper Norwood …&lt;/p&gt;&lt;/blockquote&gt;

&lt;p&gt;Where would you put the &lt;code&gt;&amp;lt;q&amp;gt;&lt;/code&gt; tags? The dialogue is interspersed with text that is not part of the quotation, but then the quotation spans more than one paragraph. It is a bit late to ask Arthur Conan Doyle to use a &lt;code&gt;&amp;lt;blockquote&amp;gt;&lt;/code&gt; instead.&lt;/p&gt;

&lt;p&gt;The obvious solution is to use real quotation marks. And if we can use real quotation marks, why do we need &lt;code&gt;&amp;lt;q&amp;gt;&lt;/code&gt; at all? We don’t have HTML elements for other punctuation. The characters exist in Unicode, they are semantically correct, and they are right there on your keyboard.&lt;/p&gt;
</content>
    </entry>

    <entry>
        <title>What is holding back the web?</title>
        <link href="http://hughesblog.co.uk/2012/07/what-is-holding-back-the-web/" />
        <id>http://hughesblog.co.uk/2012/07/what-is-holding-back-the-web/</id>
        <published>2012-07-12T00:00:00+01:00</published>
        <updated>2012-07-12T00:00:00+01:00</updated>
        <author>
            <name></name>
        </author>

        <summary>An article by Louis Lazaris appeared in Smashing Magazine this week, blaming all versions of Internet Explorer for holding back the web. I know nobody likes Internet Explorer 6, but is version 9 really that bad?</summary>

        <content type="html">&lt;p&gt;An &lt;a href=&quot;http://www.smashingmagazine.com/2012/07/09/old-browsers-are-holding-back-the-web/&quot;&gt;article by Louis Lazaris&lt;/a&gt; appeared in Smashing Magazine this week, blaming all versions of Internet Explorer for holding back the web. I know nobody likes Internet Explorer 6, but is version 9 really that bad? Nicholas C. Zakas has already written a &lt;a href=&quot;http://www.smashingmagazine.com/2012/07/12/its-time-to-stop-blaming-internet-explorer/&quot;&gt;great response&lt;/a&gt;, but I thought I might add a few points in defence of at least some versions of Internet Explorer.&lt;/p&gt;

&lt;p&gt;I would draw a major distinction between &lt;em&gt;old&lt;/em&gt; and &lt;em&gt;current&lt;/em&gt; versions of Internet Explorer. Old versions, which I would describe as version 7 and below, lack key features and contain major bugs and that means they can be a real headache for developers. Patchy and wildly unpredictable support for CSS 2.1 makes layout difficult and time-consuming. But ten years, three operating systems, and a heck of a lot of websites separate Internet Explorer 6 from Internet Explorer 9. You really cannot put them in the same category.&lt;/p&gt;

&lt;p&gt;I will admit that current versions of Internet Explorer (8 on Windows XP, 9 on Windows Vista and above) lack a few features. However, what they do support, they support well. When I view my designs in Internet Explorer 8, they might not have rounded corners, shadows, opacity, or other formatting niceties, but I can rely on them being the right size and shape. The websites still work. And if Internet Explorer 8 isn’t holding my websites back, I can hardly complain about version 9.&lt;/p&gt;

&lt;p&gt;So with a bit of progressive enhancement, I don’t see Internet Explorer as a problem. I might even argue that mobile browsers are becoming more of a limiting factor. All the major mobile browsers are tied to their operating systems and a lot of people don’t bother with the upgrade, even if it is available. Android updates are notoriously inconsistent, but I know plenty of people with old iPhones who have never updated iOS. Internet Explorer isn’t the only old browser in the wild.&lt;/p&gt;

&lt;p&gt;However, I don’t want to pass the blame on to some other browser. In fact, I don’t think any browser is “holding back” the web. All the browser manufacturers are releasing new versions, new standards are emerging, and more people are using the web in new and interesting ways than ever before. I don’t see anything holding back the web and I think it’s a great time to be a developer.&lt;/p&gt;
</content>
    </entry>

    <entry>
        <title>Simple responsive JavaScript</title>
        <link href="http://hughesblog.co.uk/2012/04/simple-responsive-javascript/" />
        <id>http://hughesblog.co.uk/2012/04/simple-responsive-javascript/</id>
        <published>2012-04-22T00:00:00+01:00</published>
        <updated>2012-04-22T00:00:00+01:00</updated>
        <author>
            <name></name>
        </author>

        <summary>There are lots of ways of creating a responsive navigation menu, but many of them involve using JavaScript to detect browser size. This is my method, which produces a collapsible menu on smaller screens without relying on JavaScript techniques for size detection.</summary>

        <content type="html">&lt;p&gt;Brad Frost recently wrote a great summary of &lt;a href=&quot;http://bradfrostweb.com/blog/web/responsive-nav-patterns/&quot;&gt;responsive navigation patterns&lt;/a&gt;. Personally, I prefer the &lt;a href=&quot;http://bradfrostweb.com/blog/web/responsive-nav-patterns/#toggle&quot;&gt;toggle method&lt;/a&gt;, which keeps the menu out of the way until you need it and that is the method I chose for my own site. Here is how I implemented it.&lt;/p&gt;

&lt;p&gt;My own approach is similar to an &lt;a href=&quot;http://filamentgroup.com/lab/responsive_design_approach_for_navigation/&quot;&gt;example by Filament Group&lt;/a&gt;, but mine completely avoids trying to detect the size of the window with JavaScript.&lt;/p&gt;

&lt;p&gt;I’ll start with a simple HTML navigation menu:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;div class=&quot;nav&quot;&amp;gt;
    &amp;lt;ul&amp;gt;
        &amp;lt;li&amp;gt;&amp;lt;a href=&quot;#&quot;&amp;gt;Lorem Ipsum&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
        &amp;lt;li&amp;gt;&amp;lt;a href=&quot;#&quot;&amp;gt;Dolor Sit Amet&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
        &amp;lt;li&amp;gt;&amp;lt;a href=&quot;#&quot;&amp;gt;Consectetur&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
    &amp;lt;/ul&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Because I am going to use a &lt;a href=&quot;http://stuffandnonsense.co.uk/projects/320andup/&quot;&gt;mobile first&lt;/a&gt; approach, the menu will start out as a vertical list:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;@media screen {

    .nav li {
        display: block;
    }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;On larger screens, the menu will be converted into a horizontal list:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;@media screen and (min-width: 60em) {

    .nav li {
        display: inline;
    }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The navigation menu will now adapt to the size of the screen. The next job is to use JavaScript to collapse the menu at small screen sizes and add a control to toggle the menu on and off.&lt;/p&gt;

&lt;p&gt;The script is very simple. The first part adds a link to the top of the menu to act as a control:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;// Get existing nav elements
var nav = document.getElementsByClassName('nav')[0];
var ul = nav.getElementsByTagName('ul')[0];

// Create new nav control elements
var control = document.createElement('div');
var link = document.createElement('a');

// Function to add control elements
var setNavControl = function() {
    link.href = '#';
    link.innerHTML = 'Show Navigation';
    control.className = 'mq-control';
    control.appendChild(link);
    nav.insertBefore(control, nav.firstChild);
    ul.className = 'mq-small-hidden';
};

// Add the nav control elements
setNavControl();
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The toggle control only needs to be visible on small screens, so I can now hide it on large screens in the stylesheet:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;@media screen and (min-width: 60em) {

    .mq-control {
        display: none;
    }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The second part of the script then toggles a class on the navigation list element when the control is clicked:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;// Function to toggle nav list class
var toggleNavControl = function(event) {
    if(ul.className === 'mq-small-hidden') {
        link.innerHTML = 'Hide Navigation';
        ul.className = '';
    } else {
        link.innerHTML = 'Show Navigation';
        ul.className = 'mq-small-hidden';
    }
    link.blur();
    return false;
};

// Call toggle function when user clicks the nav control link
link.onclick = toggleNavControl;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;In this case, the text of the link is also updated. For this to work, this class should be hidden on small screens, but visible on large screens (where there will be no toggle control). Therefore, another bit of CSS is required:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;@media screen {

    .mq-small-hidden {
        display: none;
    }

}

@media screen and (min-width: 60em) {

    .mq-small-hidden {
        display: block;
    }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The result is a navigation menu that collapses at small screen sizes but does not rely on any detection of browser size or orientation with JavaScript. It is quick to produce and accessible, and progressive enhancement means that the menu will function with or without the script.&lt;/p&gt;
</content>
    </entry>

    <entry>
        <title>Tools I use all the time</title>
        <link href="http://hughesblog.co.uk/2012/04/tools-i-use-all-the-time/" />
        <id>http://hughesblog.co.uk/2012/04/tools-i-use-all-the-time/</id>
        <published>2012-04-18T00:00:00+01:00</published>
        <updated>2012-04-18T00:00:00+01:00</updated>
        <author>
            <name></name>
        </author>

        <summary>Since I started making websites, I have been building up a list of useful tools, scripts, and other bits of software that just make my job a little bit easier. This is my current list.</summary>

        <content type="html">&lt;p&gt;Since I started making websites, I have been building up a list of useful tools, scripts, and other bits of software that just make my job a little bit easier. This is my current list.&lt;/p&gt;

&lt;dl&gt;

    &lt;dt&gt;&lt;a href=&quot;http://colorschemedesigner.com/&quot;&gt;Color Scheme Designer 3&lt;/a&gt;&lt;/dt&gt;
    &lt;dd&gt;An invaluable tool for finding complementary shades and colours, with a good range of options and a simple interface.&lt;/dd&gt;

    &lt;dt&gt;&lt;a href=&quot;http://csslint.net/&quot;&gt;CSS Lint&lt;/a&gt;&lt;/dt&gt;
    &lt;dd&gt;A &lt;a href=&quot;http://mattwilcox.net/archive/entry/id/1054/&quot;&gt;controversial choice&lt;/a&gt;, but still something I use regularly. You don’t have to do everything it says, but it will pick up errors and it might just make your code a bit more efficient. Always read the label.&lt;/dd&gt;

    &lt;dt&gt;&lt;a href=&quot;http://checkip.dyndns.org/&quot;&gt;Current IP Check&lt;/a&gt;&lt;/dt&gt;
    &lt;dd&gt;Does exactly what it says it does.&lt;/dd&gt;

    &lt;dt&gt;&lt;a href=&quot;http://whois.domaintools.com/&quot;&gt;DomainTools WHOIS Lookup&lt;/a&gt;&lt;/dt&gt;
    &lt;dd&gt;There are plenty of options for WHOIS queries, but I have always found this one the quickest and simplest.&lt;/dd&gt;

    &lt;dt&gt;&lt;a href=&quot;http://www.downforeveryoneorjustme.com/&quot;&gt;Down For Everyone Or Just Me&lt;/a&gt;&lt;/dt&gt;
    &lt;dd&gt;Also available at &lt;a href=&quot;http://www.isup.me/&quot;&gt;isup.me&lt;/a&gt;, this simple site will save a lot of shouting across the office.&lt;/dd&gt;

    &lt;dt&gt;&lt;a href=&quot;http://dummyimage.com/&quot;&gt;Dynamic Dummy Image Generator&lt;/a&gt;&lt;/dt&gt;
    &lt;dd&gt;Have you ever needed a dummy image to fill a gap in hurry? This generator is quick and simple and even prints the dimensions on the image, so you can remember what they are later.&lt;/dd&gt;

    &lt;dt&gt;&lt;a href=&quot;http://www.fontsquirrel.com/&quot;&gt;Font Squirrel&lt;/a&gt;&lt;/dt&gt;
    &lt;dd&gt;Not really a single tool, this is a great resource for finding open source web fonts. The brilliantly flexible &lt;code&gt;@font-face&lt;/code&gt; generator has also made a lot of projects a lot easier.&lt;/dd&gt;

    &lt;dt&gt;&lt;a href=&quot;http://lint.brihten.com/html/&quot;&gt;HTML Lint&lt;/a&gt;&lt;/dt&gt;
    &lt;dd&gt;You know your code is valid, but is it pretty?&lt;/dd&gt;

    &lt;dt&gt;&lt;a href=&quot;http://www.htaccesstools.com/htpasswd-generator/&quot;&gt;htpasswd generator&lt;/a&gt;&lt;/dt&gt;
    &lt;dd&gt;If you don’t have time to do it yourself, this can quickly add a bit of security to your site.&lt;/dd&gt;

    &lt;dt&gt;&lt;a href=&quot;http://ismyblogworking.com/&quot;&gt;Is My Blog Working?&lt;/a&gt;&lt;/dt&gt;
    &lt;dd&gt;This site checks your blog for errors, efficiency, and visibility. More useful than you might think.&lt;/dd&gt;

    &lt;dt&gt;&lt;a href=&quot;http://www.jshint.com/&quot;&gt;JSHint&lt;/a&gt;&lt;/dt&gt;
    &lt;dd&gt;A friendlier cousin of the venerable &lt;a href=&quot;http://www.jslint.com/&quot;&gt;JSLint&lt;/a&gt;, this code checker has plenty of options and provides really useful feedback on your JavaScript code.&lt;/dd&gt;

    &lt;dt&gt;&lt;a href=&quot;http://shancarter.com/data_converter/&quot;&gt;Mr Data Converter&lt;/a&gt;&lt;/dt&gt;
    &lt;dd&gt;What if you have some comma-delimited data that need to be in an HTML table, or a PHP array, or a JSON string, or something else entirely? Job done.&lt;/dd&gt;

    &lt;dt&gt;&lt;a href=&quot;http://pxtoem.com/&quot;&gt;PXtoEM.com&lt;/a&gt;&lt;/dt&gt;
    &lt;dd&gt;Put away the calculator. This site converts your old-fashioned &lt;code&gt;px&lt;/code&gt; units to shiny, responsive &lt;code&gt;em&lt;/code&gt; units.&lt;/dd&gt;

    &lt;dt&gt;&lt;a href=&quot;http://www.benjaminkeen.com/misc/bricss/&quot;&gt;Responsive Design Test Bookmarklet&lt;/a&gt;&lt;/dt&gt;
    &lt;dd&gt;Still endlessly resizing the window to test your responsive design? Stop that. You can also use &lt;a href=&quot;http://mattkersley.com/responsive/&quot;&gt;Matt Kersley’s&lt;/a&gt; version, but personally I find the bookmarklet more convenient.&lt;/dd&gt;

    &lt;dt&gt;&lt;a href=&quot;http://validator.nu/&quot;&gt;Validator.nu&lt;/a&gt;&lt;/dt&gt;
    &lt;dd&gt;The original and best HTML5 validator.&lt;/dd&gt;

&lt;/dl&gt;


&lt;p&gt;And that is my list.&lt;/p&gt;
</content>
    </entry>

    <entry>
        <title>Query without jQuery</title>
        <link href="http://hughesblog.co.uk/2012/04/query-without-jquery/" />
        <id>http://hughesblog.co.uk/2012/04/query-without-jquery/</id>
        <published>2012-04-14T00:00:00+01:00</published>
        <updated>2012-04-14T00:00:00+01:00</updated>
        <author>
            <name></name>
        </author>

        <summary>One of the great advantages of using jQuery is that it makes it easy to select a set of elements on the page using the familiar syntax of CSS. But did you know you can also do that without jQuery?</summary>

        <content type="html">&lt;p&gt;One of the great advantages of using &lt;a href=&quot;http://jquery.com/&quot;&gt;jQuery&lt;/a&gt; is that it makes it easy to select a set of elements on the page using the familiar syntax of CSS. But did you know you can also do that without jQuery?&lt;/p&gt;

&lt;p&gt;The &lt;a href=&quot;http://www.w3.org/TR/selectors-api/&quot;&gt;Selectors API&lt;/a&gt; has been around for a while now, but not many people know about it. The API is supported by all the recent versions of the major browsers, including Internet Explorer 8 and above. It provides two methods, &lt;code&gt;querySelector()&lt;/code&gt; and &lt;code&gt;querySelectorAll()&lt;/code&gt;, which take a CSS selector as an argument and which return a DOM object.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;querySelector()&lt;/code&gt; method only returns the first match, whereas the &lt;code&gt;querySelectorAll()&lt;/code&gt; method returns all the matches as a collection of objects. For example, the following will return the first element with the example class:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;document.querySelector('.example');
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And this will return &lt;em&gt;all&lt;/em&gt; the elements with the &lt;code&gt;example&lt;/code&gt; class &lt;em&gt;and&lt;/em&gt; the third &lt;code&gt;span&lt;/code&gt; element child of each &lt;code&gt;p&lt;/code&gt; element:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;document.querySelectorAll('.example, p &amp;gt; span:nth-of-type(3)');
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Using these methods, it is possible to select a relatively complex range of elements very quickly and easily. Obviously, these methods will only work with the CSS selectors actually supported by the browser and so it is not a replacement for all the possible jQuery selectors. And if you need to support Internet Explorer 7 or below, you are out of luck. But for other situations, it is a simple method that might save you some time and bandwidth.&lt;/p&gt;
</content>
    </entry>

    <entry>
        <title>Adding multiple load events</title>
        <link href="http://hughesblog.co.uk/2012/03/adding-multiple-load-events/" />
        <id>http://hughesblog.co.uk/2012/03/adding-multiple-load-events/</id>
        <published>2012-03-08T00:00:00+00:00</published>
        <updated>2012-03-08T00:00:00+00:00</updated>
        <author>
            <name></name>
        </author>

        <summary>This is an old tip, but it’s still useful. With a simple function, you can add multiple load events to a page while maintaining cross-browser compatibility.</summary>

        <content type="html">&lt;p&gt;This is an old tip, but it’s still useful. Starting a function when your page loads using &lt;code&gt;window.onload&lt;/code&gt; is well supported, but you can only add one onload event. The newer &lt;code&gt;window.addEventListener&lt;/code&gt; method should make this easy, but it doesn’t work with old versions of Internet Explorer. However, with a simple function, you can add as many events as you want without worrying about backwards compatibility.&lt;/p&gt;

&lt;p&gt;The trick is to check if &lt;code&gt;window.onload&lt;/code&gt; already exists and then to make a copy of it that can be added to a new window.onload event.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;function addLoadEvent(fn) {
    var old = window.onload;
    if(typeof window.onload !== 'function') {
        window.onload = fn;
    } else {
        window.onload = function() {
            old();
            fn();
        };
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I first spotted this in &lt;a href=&quot;http://www.sitepoint.com/books/jsant1/&quot;&gt;&lt;cite&gt;The JavaScript Anthology&lt;/cite&gt;&lt;/a&gt; by James Edwards and Cameron Adams, but I’ve seen it in all sorts of places since then.&lt;/p&gt;
</content>
    </entry>

    <entry>
        <title>Touch icons demystified</title>
        <link href="http://hughesblog.co.uk/2012/03/touch-icons-demystified/" />
        <id>http://hughesblog.co.uk/2012/03/touch-icons-demystified/</id>
        <published>2012-03-05T00:00:00+00:00</published>
        <updated>2012-03-05T00:00:00+00:00</updated>
        <author>
            <name></name>
        </author>

        <content type="html">&lt;p&gt;If you have ever struggled to get your site’s icons working on smart phones, you should definitely check out Mathias Bynens’s &lt;a href=&quot;http://mathiasbynens.be/notes/touch-icons&quot;&gt;excellent post on touch icons&lt;/a&gt;. A simple, clear explanation that leaves us with no excuse for our missing icons.&lt;/p&gt;
</content>
    </entry>

    <entry>
        <title>Doing more with links</title>
        <link href="http://hughesblog.co.uk/2012/03/doing-more-with-links/" />
        <id>http://hughesblog.co.uk/2012/03/doing-more-with-links/</id>
        <published>2012-03-02T00:00:00+00:00</published>
        <updated>2012-03-02T00:00:00+00:00</updated>
        <author>
            <name></name>
        </author>

        <summary>We all know how to write a link to another page or a link to an email address. But did you know that you can also make a phone call or send a text message with a hyperlink?</summary>

        <content type="html">&lt;p&gt;Hyperlinks are the most important part of any web page. A page without a link is a dead end, no more useful than a printed document. However, you can do a lot more with a hyperlink than simply linking to other pages.&lt;/p&gt;

&lt;p&gt;As a web developer, writing a hyperlink to another page is probably one of the first things you learned:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;a href=&quot;http://www.example.com/&quot;&amp;gt;example web page&amp;lt;/a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And then there is the mailto: protocol for linking to an email address:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;a href=&quot;mailto:example@example.com&quot;&amp;gt;example email&amp;lt;/a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;However, did you know that you can also use mailto: links to specify multiple email addresses, subject lines, and even the text of the email itself:&lt;/p&gt;

&lt;pre&gt;&amp;lt;a href=&quot;mailto:&amp;#8203;example@example.com,&amp;#8203;second@example.com,&amp;#8203;third@example.com?from=fromaddress&amp;#8203;&amp;amp;bcc=addresslist&amp;#8203;&amp;amp;cc=addresslist&amp;#8203;&amp;amp;reply-to=address&amp;#8203;&amp;amp;subject=subject%20text&amp;#8203;&amp;amp;body=body&amp;#8203;%20text&quot;&amp;gt;example email&amp;lt;/a&amp;gt;&lt;/pre&gt;


&lt;p&gt;Smart phones provide more options, including the tel: protocol for telephone numbers. You cannot use spaces in the number, but you can add hyphens anywhere you want to make your code a bit more readable.&lt;/p&gt;

&lt;pre&gt;&amp;lt;a href=&quot;tel:&amp;#8203;+44-1234-567890&quot;&amp;gt;example telephone number&amp;lt;/a&amp;gt;&lt;/pre&gt;


&lt;p&gt;And you can even use a hyperlink to send a text message:&lt;/p&gt;

&lt;pre&gt;&amp;lt;a href=&quot;sms:&amp;#8203;+44-1234-567899&quot;&amp;gt;text message&amp;lt;/a&amp;gt;&lt;/pre&gt;


&lt;p&gt;As with mailto: links, you can specify multiple recipients and text of the message itself:&lt;/p&gt;

&lt;pre&gt;&amp;lt;a href=&quot;sms:&amp;#8203;+44-1234-567890,&amp;#8203;+44-0987-654321?body=body&amp;#8203;%20text&quot;&amp;gt;example text message&amp;lt;/a&amp;gt;&lt;/pre&gt;


&lt;p&gt;Hyperlinks have always been vital for connecting web pages together. Now you can use them to connect to things outside of the internet as well.&lt;/p&gt;
</content>
    </entry>


</feed>
