登录
[HTML5 Boilerplate homepage](http://html5boilerplate.com) | [Documentation table of contents](TOC.md) # Usage Once you have cloned or downloaded HTML5 Boilerplate, creating a site or app usually involves the following: 1. Set up the basic structure of the site. 2. Add some content, style, and functionality. 3. Run your site locally to see how it looks. 4. (Optionally run a build script to automate the optimization of your site - e.g. [ant build script](https://github.com/h5bp/ant-build-script) or [node build script](https://github.com/h5bp/node-build-script)). 5. Deploy your site. ## Basic structure A basic HTML5 Boilerplate site initially looks something like this: ``` . ├── css │ ├── main.css │ └── normalize.css ├── doc ├── img ├── js │ ├── main.js │ ├── plugins.js │ └── vendor │ ├── jquery.min.js │ └── modernizr.min.js ├── .htaccess ├── 404.html ├── apple-touch-icon-precomposed.png ├── index.html ├── humans.txt ├── robots.txt ├── crossdomain.xml └── favicon.ico ``` What follows is a general overview of each major part and how to use them. ### css This directory should contain all your project's CSS files. It includes some initial CSS to help get you started from a solid foundation. [About the CSS](css.md). ### doc This directory contains all the HTML5 Boilerplate documentation. You can use it as the location and basis for your own project's documentation. ### js This directory should contain all your project's JS files. Libraries, plugins, and custom code can all be included here. It includes some initial JS to help get you started. [About the JavaScript](js.md). ### .htaccess The default web server configs are for Apache. For more information, please refer to the [Apache Server Configs documentation](https://github.com/h5bp/server-configs-apache/tree/master/doc). Host your site on a server other than Apache? You're likely to find the corresponding server configs project listed in our [Server Configs ](https://github.com/h5bp/server-configs/blob/master/README.md) repository. ### 404.html A helpful custom 404 to get you started. ### index.html This is the default HTML skeleton that should form the basis of all pages on your site. If you are using a server-side templating framework, then you will need to integrate this starting HTML with your setup. Make sure that you update the URLs for the referenced CSS and JavaScript if you modify the directory structure at all. If you are using Google Analytics, make sure that you edit the corresponding snippet at the bottom to include your analytics ID. ### humans.txt Edit this file to include the team that worked on your site/app, and the technology powering it. ### robots.txt Edit this file to include any pages you need hidden from search engines. ### crossdomain.xml A template for working with cross-domain requests. [About crossdomain.xml](crossdomain.md). ### Icons Replace the default `favicon.ico` and Apple Touch Icon with your own. If you want to use different Apple Touch Icons for different resolutions please refer to the [according documentation](extend.md#apple-touch-icons). You might want to check out Hans' handy [HTML5 Boilerplate Favicon and Apple Touch Icon PSD-Template](http://drublic.de/blog/html5-boilerplate-favicons-psd-template/). [HTML5 Boilerplate homepage](http://html5boilerplate.com) | [Documentation table of contents](TOC.md) # crossdomain.xml A cross-domain policy file is an XML document that grants a web client—such as Adobe Flash Player, Adobe Reader, etc., permission to handle data across multiple domains. When a client hosts content from a particular source domain and that content makes requests directed towards a domain other than its own, the remote domain would need to host a cross-domain policy file that grants access to the source domain, allowing the client to continue with the transaction. Policy files grant read access to data, permit a client to include custom headers in cross-domain requests, and are also used with sockets to grant permissions for socket-based connections. For full details, check out Adobe's article about the [cross-domain policy file specification](http://www.adobe.com/devnet/articles/crossdomain_policy_file_spec.html). [HTML5 Boilerplate homepage](http://html5boilerplate.com) | [Documentation table of contents](TOC.md) # The CSS The HTML5 Boilerplate starting CSS includes: * [Normalize.css](https://github.com/necolas/normalize.css). * Useful HTML5 Boilerplate defaults. * Common helpers. * Placeholder media queries. * Print styles. This starting CSS does not rely on the presence of conditional classnames, conditional style sheets, or Modernizr. It is ready to use whatever your development preferences happen to be. ## Normalize.css Normalize.css is a modern, HTML5-ready alternative to CSS resets. It contains extensive inline documentation. Please refer to the [Normalize.css project](http://necolas.github.com/normalize.css/) for more information. ## HTML5 Boilerplate defaults This project includes a handful of base styles that build upon Normalize.css. These include: * Basic typography settings to provide improved text readability by default. * Protection against unwanted `text-shadow` during text highlighting. * Tweaks to default image alignment, fieldsets, and textareas. * A pretty Chrome Frame prompt. You are free to modify or add to these base styles as your project requires. ## Common helpers #### `.ir` Add the `.ir` class to any element you are applying image-replacement to. When replacing an element's content with an image, make sure to also set a specific `background-image: url(pathtoimage.png);`, `width`, and `height` so that your replacement image appears. #### `.hidden` Add the `.hidden` class to any elements that you want to hide from all presentations, including screen readers. It could be an element that will be populated later with JavaScript or an element you will hide with JavaScript. Do not use this for SEO keyword stuffing. That is just not cool. #### `.visuallyhidden` Add the `.visuallyhidden` class to hide text from browsers but make it available for screen readers. You can use this to hide text that is specific to screen readers but that other users should not see. [About invisible content](http://www.webaim.org/techniques/css/invisiblecontent/), [Hiding content for accessibility](http://snook.ca/archives/html_and_css/hiding-content-for-accessibility), [HTML5 Boilerplate issue/research](https://github.com/h5bp/html5-boilerplate/issues/194/). #### `.invisible` Add the `.invisible` class to any element you want to hide without affecting layout. When you use `display: none` an element is effectively removed from the layout. But in some cases you want the element to simply be invisible while remaining in the flow and not affecting the positioning of surrounding content. #### `.clearfix` Adding `.clearfix` to an element will ensure that it always fully contains its floated children. There have been many variants of the clearfix hack over the years, and there are other hacks that can also help you to contain floated children, but the HTML5 Boilerplate currently uses the [micro clearfix](http://nicolasgallagher.com/micro-clearfix-hack/). ## Media Queries The boilerplate makes it easy to get started with a "Mobile First" and [Responsive Web Design](http://www.alistapart.com/articles/responsive-web-design/) approach to development. But it's worth remembering that there are [no silver bullets](http://www.cloudfour.com/css-media-query-for-mobile-is-fools-gold/). We include a placeholder Media Queries to build up your mobile styles for wider viewports and high-resolution displays. It's recommended that you adapt these Media Queries based on the content of your site rather than mirroring the fixed dimensions of specific devices. If you do not want to take a "Mobile First" approach, you can simply edit or remove these placeholder Media Queries. One possibility would be to work from wide viewports down and use `max-width` MQs instead, e.g., `@media only screen and (max-width: 480px)`. Take a look into the [Mobile Boilerplate](https://github.com/h5bp/mobile-boilerplate) for features that are useful when developing mobile wep apps. ## Print styles * Print styles are inlined to [reduce the number of page requests](http://www.phpied.com/delay-loading-your-print-css/). * We strip all background colors, change the font color to black and remove text-shadow. This is meant to [help save printer ink and make the printing process much faster](http://www.sanbeiji.com/archives/953). * Anchors do not need colors to indicate they are linked. They are underlined to indicate so. * Anchors and Abbreviations are expanded to indicate where users reading the printed page can refer to. * But we do not want to show link text for image replaced elements (given that they are primarily images). ### Paged media styles * Paged media is supported only in a [few browsers](http://en.wikipedia.org/wiki/Comparison_of_layout_engines_%28Cascading_Style_Sheets%29#Grammar_and_rules). * Paged media support means browsers would know how to interpret instructions on breaking content into pages and on orphans/widows. * We use `page-break-inside: avoid;` to prevent an image and table row from being split into two different pages, so use the same `page-break-inside: avoid;` for that as well. * Headings should always appear with the text they are titles for. So, we ensure headings never appear in a different page than the text they describe by using `page-break-after: avoid;`. * We also apply a default margin for the page specified in `cm`. * We do not want [orphans and widows](http://en.wikipedia.org/wiki/Widows_and_orphans) to appear on pages you print. So, by defining `orphans: 3` and `widows: 3` you define the minimal number of words that every line should contain. [HTML5 Boilerplate homepage](http://html5boilerplate.com) | [Documentation table of contents](TOC.md) # Extend and customise HTML5 Boilerplate Here is some useful advice for how you can make your project with HTML5 Boilerplate even better. We don't want to include it all by default, as not everything fits with everyone's needs. ## DNS prefetching In short, DNS Prefetching is a method of informing the browser of domain names referenced on a site so that the client can resolve the DNS for those hosts, cache them, and when it comes time to use them, have a faster turn around on the request. ### Implicit prefetches There is a lot of prefetching done for you automatically by the browser. When the browser encounters an anchor in your html that does not share the same domain name as the current location the browser requests, from the client OS, the IP address for this new domain. The client first checks its cache and then, lacking a cached copy, makes a request from a DNS server. These requests happen in the background and are not meant to block the rendering of the page. The goal of this is that when the foreign IP address is finally needed it will already be in the client cache and will not block the loading of the foreign content. Less requests result in faster page load times. The perception of this is increased on a mobile platform where DNS latency can be greater. #### Disable implicit prefetching ```html ``` Even with X-DNS-Prefetch-Control meta tag (or http header) browsers will still prefetch any explicit dns-prefetch links. **_WARNING:_** THIS MAY MAKE YOUR SITE SLOWER IF YOU RELY ON RESOURCES FROM FOREIGN DOMAINS. ### Explicit prefetches Typically the browser only scans the HTML for foreign domains. If you have resources that are outside of your HTML (a javascript request to a remote server or a CDN that hosts content that may not be present on every page of your site, for example) then you can queue up a domain name to be prefetched. ```html ``` You can use as many of these as you need, but it's best if they are all immediately after the [Meta Charset](https://developer.mozilla.org/en/HTML/Element/meta#attr-charset) element (which should go right at the top of the `head`), so the browser can act on them ASAP. #### Common Prefetch Links Amazon S3: ```html ``` Google APIs: ```html ``` Microsoft Ajax Content Delivery Network: ```html ``` ### Browser support for DNS prefetching Chrome, Firefox 3.5+, Safari 5+, Opera (Unknown), IE 9 (called "Pre-resolution" on blogs.msdn.com) ### Further reading about DNS prefetching * https://developer.mozilla.org/En/Controlling_DNS_prefetching * http://dev.chromium.org/developers/design-documents/dns-prefetching * http://www.apple.com/safari/whats-new.html * http://blogs.msdn.com/b/ie/archive/2011/03/17/internet-explorer-9-network-performance-improvements.aspx * http://dayofjs.com/videos/22158462/web-browsers_alex-russel ## Search ### Direct search spiders to your sitemap [Learn how to make a sitemap](http://www.sitemaps.org/protocol.php) ```html ``` ### Hide pages from search engines According to Heather Champ, former community manager at Flickr, you should not allow search engines to index your "Contact Us" or "Complaints" page if you value your sanity. This is an HTML-centric way of achieving that. ```html ``` **_WARNING:_** DO NOT INCLUDE ON PAGES THAT SHOULD APPEAR IN SEARCH ENGINES. ### Firefox and IE Search Plugins Sites with in-site search functionality should be strongly considered for a browser search plugin. A "search plugin" is an XML file which defines how your plugin behaves in the browser. [How to make a browser search plugin](http://www.google.com/search?ie=UTF-8&q=how+to+make+browser+search+plugin). ```html ``` ## Internet Explorer ### Prompt users to switch to "Desktop Mode" in IE10 Metro IE10 does not support plugins, such as Flash, in Metro mode. If your site requires plugins, you can let users know that via the X-UA-Compatible meta element, which will prompt them to switch to Desktop Mode. ```html ``` Here's what it looks like alongside H5BP's default X-UA-Compatible values: ```html ``` You can find more information in [Microsoft's IEBlog post about prompting for plugin use in IE10 Metro Mode](http://blogs.msdn.com/b/ie/archive/2012/01/31/web-sites-and-a-plug-in-free-web.aspx). ### IE Pinned Sites (IE9+) Enabling your application for pinning will allow IE9 users to add it to their Windows Taskbar and Start Menu. This comes with a range of new tools that you can easily configure with the elements below. See more [documentation on IE9 Pinned Sites](http://msdn.microsoft.com/en-us/library/gg131029.aspx). ### Name the Pinned Site for Windows Without this rule, Windows will use the page title as the name for your application. ```html ``` ### Give your Pinned Site a tooltip You know — a tooltip. A little textbox that appears when the user holds their mouse over your Pinned Site's icon. ```html ``` ### Set a default page for your Pinned Site If the site should go to a specific URL when it is pinned (such as the homepage), enter it here. One idea is to send it to a special URL so you can track the number of pinned users, like so: `http://www.example.com/index.html?pinned=true` ```html ``` ### Recolor IE's controls manually for a Pinned Site IE9+ will automatically use the overall color of your Pinned Site's favicon to shade its browser buttons. UNLESS you give it another color here. Only use named colors (`red`) or hex colors (`#ff0000`). ```html ``` ### Manually set the window size of a Pinned Site If the site should open at a certain window size once pinned, you can specify the dimensions here. It only supports static pixel dimensions. 800x600 minimum. ```html ``` ### Jump List "Tasks" for Pinned Sites Add Jump List Tasks that will appear when the Pinned Site's icon gets a right-click. Each Task goes to the specified URL, and gets its own mini icon (essentially a favicon, a 16x16 .ICO). You can add as many of these as you need. ```html ``` ### (Windows 8) High quality visuals for Pinned Sites Windows 8 adds the ability for you to provide a PNG tile image and specify the tile's background color. [Full details on the IE blog](http://blogs.msdn.com/b/ie/archive/2012/06/08/high-quality-visuals-for-pinned-sites-in-windows-8.aspx). * Create a 144x144 image of your site icon, filling all of the canvas, and using a transparent background. * Save this image as a 32-bit PNG and optimize it without reducing colour-depth. It can be named whatever you want (e.g. `metro-tile.png`). * To reference the tile and its color, add the HTML `meta` elements described in the IE Blog post. ### (Windows 8) Badges for Pinned Sites IE10 will poll an XML document for badge information to display on your app's tile in the Start screen. The user will be able to receive these badge updates even when your app isn't actively running. The badge's value can be a number, or one of a predefined list of glyphs. * [Tutorial on IEBlog with link to badge XML schema](http://blogs.msdn.com/b/ie/archive/2012/04/03/pinned-sites-in-windows-8.aspx) * [Available badge values](http://msdn.microsoft.com/en-us/library/ie/br212849.aspx) ```html ``` ### Disable link highlighting upon tap in IE10 Similar to [-webkit-tap-highlight-color](http://davidwalsh.name/mobile-highlight-color) in iOS Safari. Unlike that CSS property, this is an HTML meta element, and it's value is boolean rather than a color. It's all or nothing. ```html ``` You can read about this useful element and more techniques in [Microsoft's documentation on adapting WebKit-oriented apps for IE10](http://blogs.windows.com/windows_phone/b/wpdev/archive/2012/11/15/adapting-your-webkit-optimized-site-for-internet-explorer-10.aspx). ### Suppress IE6 image toolbar Kill IE6's pop-up-on-mouseover toolbar for images that can interfere with certain designs and be pretty distracting in general. ```html ``` ## Social Networks ### Facebook Open Graph data You can control the information that Facebook and others display when users share your site. Below are just the most basic data points you might need. For specific content types (including "website"), see [Facebook's built-in Open Graph content templates](https://developers.facebook.com/docs/opengraph/objects/builtin/). Take full advantage of Facebook's support for complex data and activity by following the [Open Graph tutorial](https://developers.facebook.com/docs/opengraph/tutorial/). ```html ``` ### Twitter Cards Twitter provides a snippet specification that serves a similar purpose to Open Graph. In fact, Twitter will use Open Graph when Cards is not available. Note that, as of this writing, Twitter requires that app developers activate Cards on a per-domain basis. You can read more about the various snippet formats and application process in the [official Twitter Cards documentation](https://dev.twitter.com/docs/cards). ```html ``` ## URLs ### Canonical URL Signal to search engines and others "Use this URL for this page!" Useful when parameters after a `#` or `?` is used to control the display state of a page. `http://www.example.com/cart.html?shopping-cart-open=true` can be indexed as the cleaner, more accurate `http://www.example.com/cart.html`. ```html ``` ### Official shortlink Signal to the world "This is the shortened URL to use this page!" Poorly supported at this time. Learn more by reading the [article about shortlinks on the Microformats wiki](http://microformats.org/wiki/rel-shortlink). ```html ``` ## News Feeds ### RSS Have an RSS feed? Link to it here. Want to [learn how to write an RSS feed from scratch](http://www.rssboard.org/rss-specification)? ```html ``` ### Atom Atom is similar to RSS, and you might prefer to use it instead of or in addition to it. [See what Atom's all about](http://www.atomenabled.org/developers/syndication/). ```html ``` ### Pingbacks Your server may be notified when another site links to yours. The href attribute should contain the location of your pingback service. ```html ``` * High-level explanation: http://codex.wordpress.org/Introduction_to_Blogging#Pingbacks * Step-by-step example case: http://www.hixie.ch/specs/pingback/pingback-1.0#TOC5 * PHP pingback service: http://blog.perplexedlabs.com/2009/07/15/xmlrpc-pingbacks-using-php/ ## App Stores ### Install a Chrome Web Store app Users can install a Chrome app directly from your website, as long as the app and site have been associated via Google's Webmaster Tools. Read more on [Chrome Web Store's Inline Installation docs](https://developers.google.com/chrome/web-store/docs/inline_installation). ```html ``` ### Smart App Banners in iOS 6 Safari Stop bothering everyone with gross modals advertising your entry in the App Store. This bit of code will unintrusively allow the user the option to download your iOS app, or open it with some data about the user's current state on the website. ```html ``` ## Google Analytics augments ### More tracking settings The [optimized Google Analytics snippet](http://mathiasbynens.be/notes/async-analytics-snippet) included with HTML5 Boilerplate includes something like this: ```js var _gaq = [['_setAccount', 'UA-XXXXX-X'], ['_trackPageview']]; ``` In case you need more settings, just extend the array literal instead of [`.push()`ing to the array](http://mathiasbynens.be/notes/async-analytics-snippet#dont-push-it) afterwards: ```js var _gaq = [['_setAccount', 'UA-XXXXX-X'], ['_trackPageview'], ['_setAllowAnchor', true]]; ``` ### Anonymize IP addresses In some countries, no personal data may be transferred outside jurisdictions that do not have similarly strict laws (i.e. from Germany to outside the EU). Thus a webmaster using the Google Analytics script may have to ensure that no personal (trackable) data is transferred to the US. You can do that with [the `_gat.anonymizeIp` option](http://code.google.com/apis/analytics/docs/gaJS/gaJSApi_gat.html#_gat._anonymizeIp). In use it looks like this: ```js var _gaq = [['_setAccount', 'UA-XXXXX-X'], ['_gat._anonymizeIp'], ['_trackPageview']]; ``` ### Track jQuery AJAX requests in Google Analytics An article by @JangoSteve explains how to [track jQuery AJAX requests in Google Analytics](http://www.alfajango.com/blog/track-jquery-ajax-requests-in-google-analytics/). Add this to `plugins.js`: ```js /* * Log all jQuery AJAX requests to Google Analytics * See: http://www.alfajango.com/blog/track-jquery-ajax-requests-in-google-analytics/ */ if (typeof _gaq !== "undefined" && _gaq !== null) { $(document).ajaxSend(function(event, xhr, settings){ _gaq.push(['_trackPageview', settings.url]); }); } ``` ### Track JavaScript errors in Google Analytics Add this function after `_gaq` is defined: ```js (function(window){ var undefined, link = function (href) { var a = window.document.createElement('a'); a.href = href; return a; }; window.onerror = function (message, file, line, column) { var host = link(file).hostname; _gaq.push([ '_trackEvent', (host == window.location.hostname || host == undefined || host == '' ? '' : 'external ') + 'error', message, file + ' LINE: ' + line + (column ? ' COLUMN: ' + column : ''), undefined, undefined, true ]); }; }(window)); ``` ### Track page scroll Add this function after `_gaq` is defined: ```js $(function(){ var isDuplicateScrollEvent, scrollTimeStart = new Date, $window = $(window), $document = $(document), scrollPercent; $window.scroll(function() { scrollPercent = Math.round(100 * ($window.height() + $window.scrollTop())/$document.height()); if (scrollPercent > 90 && !isDuplicateScrollEvent) { //page scrolled to 90% isDuplicateScrollEvent = 1; _gaq.push(['_trackEvent', 'scroll', 'Window: ' + $window.height() + 'px; Document: ' + $document.height() + 'px; Time: ' + Math.round((new Date - scrollTimeStart )/1000,1) + 's', undefined, undefined, true ]); } }); }); ``` ## iOS Web Apps There are a couple of meta tags that provide information about a web app when added to the Home Screen on iOS. Adding `apple-mobile-web-app-capable` will make your web app chrome-less and provide the default iOS app view. You can control the color scheme of the default view by adding `apple-mobile-web-app-status-bar-style`. ```html ``` You can use `apple-mobile-web-app-title` to add a specific sites name for the Home Screen icon. This works since iOS 6. ```html ``` For further information please read the [official documentation](http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html) on Apple's site. ### Apple Touch Icons Touch Icons can be seen as the favicons of mobile devices and tablets. If your site or icons are in a sub-directory, you will need to reference the icons using `link` elements placed in the HTML `head` of your document. ```html ``` The main sizes of the icons on iOS are: * iPad, high-resolution display, iOS 7: 152x152 * iPad, high-resolution display, iOS ≤ 6: 144x144 * iPhone, high-resolution display, iOS 7: 120x120 * iPhone, high-resolution display, iOS ≤ 6: 114x114 * iPad, non-Retina, iOS ≤ 6: 72x72 For non-Retina iPhone, iPod Touch, and Android 2.1+ devices you can use the example from above or replace the `apple-touch-icon-precomposed.png` within this project's root folder. Please refer to Mathias' [article on Touch Icons](http://mathiasbynens.be/notes/touch-icons) for a comprehensive overview. ### Apple Touch Startup Image Apart from that it is possible to add start-up screens for web apps on iOS. This basically works by defining `apple-touch-startup-image` with an according link to the image. Since iOS devices have different screen resolutions it is necessary to add media queries to detect which image to load. Here is an example for a retina iPhone: ```html ``` However, it is possible to detect which start-up image to use with JavaScript. The Mobile Boilerplate provides a useful function for this. Please see [helpers.js](https://github.com/h5bp/mobile-boilerplate/blob/master/js/helper.js#L354) for the implementation. ## Miscellaneous * Use [HTML5 polyfills](https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills). * Use [Microformats](http://microformats.org/wiki/Main_Page) (via [microdata](http://microformats.org/wiki/microdata)) for optimum search results [visibility](http://googlewebmastercentral.blogspot.com/2009/05/introducing-rich-snippets.html). * If you're building a web app you may want [native style momentum scrolling in iOS5](http://johanbrook.com/browsers/native-momentum-scrolling-ios-5/) using `-webkit-overflow-scrolling: touch`. * Avoid development/stage websites "leaking" into SERPs (search engine results page) by [implementing X-Robots-tag headers](https://github.com/h5bp/html5-boilerplate/issues/804). * Screen readers currently have less-than-stellar support for HTML5 but the JS script [accessifyhtml5.js](https://github.com/yatil/accessifyhtml5.js) can help increase accessibility by adding ARIA roles to HTML5 elements. *Many thanks to [Brian Blakely](https://github.com/brianblakely) for contributing much of this information.* [HTML5 Boilerplate homepage](http://html5boilerplate.com) | [Documentation table of contents](TOC.md) # Frequently asked questions ### Why is the URL for jQuery without "http"? This is an intentional use of [protocol-relative URLs](http://paulirish.com/2010/the-protocol-relative-url/) **N.B.** Using a protocol-relative URL for files that exist on a CDN is problematic when you try to view your local files directly in the browser. The browser will attempt to fetch the file from your local file system. We recommend that you use a local server to test your pages (or Dropbox). This can be done using Python 2.x by running `python -m SimpleHTTPServer` or Python 3.x with `python -m http.server` from your local directory, using Ruby by installing and running [asdf](https://rubygems.org/gems/asdf), and by installing any one of XAMPP, MAMP, or WAMP. ### Why don't you automatically load the latest version of jQuery from the Google CDN? 1. The latest version of jQuery may not be compatible with the existing plugins/code on the site. Version updating should be an intentional decision. 2. The latest version has a very short `max-age=3600` compares to the specific version of `max-age=31536000`, which means you won't get the benefits of long-term caching. ### Why is the Google Analytics code at the bottom? Google recommends it be placed the `head`. The advantage to placing it in the `head` is that you will track a user's pageview even if they leave the page before it has been fully loaded. However, putting the code at the bottom keeps all the scripts together and reinforces that scripts at the bottom are the right move. ### How can I integrate [Twitter Bootstrap](http://twitter.github.com/bootstrap/) with HTML5 Boilerplate? You can use [Initializr](http://initializr.com) to create a custom build that includes HTML5 Boilerplate with Twitter Bootstrap. Read more about how [HTML5 Boilerplate and Twitter Bootstrap complement each other](http://www.quora.com/Is-Bootstrap-a-complement-OR-an-alternative-to-HTML5-Boilerplate-or-viceversa/answer/Nicolas-Gallagher). ### How do I prevent phone numbers looking twice as large and having a Skype highlight? If this is occurring, it is because a user has the Skype browser extension installed. Use the following CSS to prevent Skype from formatting the numbers on your page: ```css span.skype_pnh_container { display: none !important; } span.skype_pnh_print_container { display: inline !important; } ``` ### Do I need to upgrade my sites each time a new version of HTML5 Boilerplate is released? No. You don't normally replace the foundations of a house once it has been built. There is nothing stopping you from trying to work in the latest changes but you'll have to assess the costs/benefits of doing so. ### Where can I get help for support questions? Please ask for help on [StackOverflow](http://stackoverflow.com/questions/tagged/html5boilerplate). [HTML5 Boilerplate homepage](http://html5boilerplate.com) | [Documentation table of contents](TOC.md) # The JavaScript Information about the default JavaScript included in the project. ## main.js This file can be used to contain or reference your site/app JavaScript code. For larger projects, you can make use of a JavaScript module loader, like [Require.js](http://requirejs.org/), to load any other scripts you need to run. ## plugins.js This file can be used to contain all your plugins, such as jQuery plugins and other 3rd party scripts. One approach is to put jQuery plugins inside of a `(function($){ ... })(jQuery);` closure to make sure they're in the jQuery namespace safety blanket. Read more about [jQuery plugin authoring](http://docs.jquery.com/Plugins/Authoring#Getting_Started) ## vendor This directory can be used to contain all 3rd party library code. Minified versions of the latest jQuery and Modernizr libraries are included by default. You may wish to create your own [custom Modernizr build](http://www.modernizr.com/download/). [HTML5 Boilerplate homepage](http://html5boilerplate.com) | [Documentation table of contents](TOC.md) # The HTML ## Conditional `html` classes A series of IE conditional comments apply the relevant IE-specific classes to the `html` tag. This provides one method of specifying CSS fixes for specific legacy versions of IE. While you may or may not choose to use this technique in your project code, HTML5 Boilerplate's default CSS does not rely on it. When using the conditional classes technique, applying classes to the `html` element has several benefits: * It avoids a [file blocking issue](http://webforscher.wordpress.com/2010/05/20/ie-6-slowing-down-ie-8/) discovered by Stoyan Stefanov and Markus Leptien. * It avoids the need for an empty comment that also fixes the above issue. * CMSes like WordPress and Drupal use the body class more heavily. This makes integrating there a touch simpler. * It still validates as HTML5. * It uses the same element as Modernizr (and Dojo). That feels nice. * It can improve the clarity of code in multi-developer teams. ## The `no-js` class Allows you to more easily explicitly add custom styles when JavaScript is disabled (`no-js`) or enabled (`js`). More here: [Avoiding the FOUC](http://paulirish.com/2009/avoiding-the-fouc-v3/). ## The order of meta tags, and ` ` As recommended by [the HTML5 spec](http://www.whatwg.org/specs/web-apps/current-work/complete/semantics.html#charset) (4.2.5.5 Specifying the document's character encoding), add your charset declaration early (before any ASCII art ;) to avoid a potential [encoding-related security issue](http://code.google.com/p/doctype-mirror/wiki/ArticleUtf7) in IE. It should come in the first [1024 bytes](http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#charset). The charset should also come before the ` ` tag, due to [potential XSS vectors](http://code.google.com/p/doctype-mirror/wiki/ArticleUtf7). The meta tag for compatibility mode [needs to be before all elements except title and meta](http://h5bp.com/f "Defining Document Compatibility - MSDN"). And that same meta tag can only be invoked for Google Chrome Frame if it is within the [first 1024 bytes](http://code.google.com/p/chromium/issues/detail?id=23003). ## X-UA-Compatible This makes sure the latest version of IE is used in versions of IE that contain multiple rendering engines. Even if a site visitor is using IE8 or IE9, it's possible that they're not using the latest rendering engine their browser contains. To fix this, use: ```html ``` The `meta` tag tells the IE rendering engine it should use the latest, or edge, version of the IE rendering environment. This `meta` tag ensures that anyone browsing your site in IE is treated to the best possible user experience that their browser can offer. This line breaks validation. To avoid this edge case issue it is recommended that you **remove this line and use the `.htaccess`** (or other server config) to send these headers instead. You also might want to read [Validating: X-UA-Compatible](http://groups.google.com/group/html5boilerplate/browse_thread/thread/6d1b6b152aca8ed2). If you are serving your site on a non-standard port, you will need to set this header on the server-side. This is because the IE preference option 'Display intranet sites in Compatibility View' is checked by default. ## Mobile viewport There are a few different options that you can use with the [`viewport` meta tag](https://docs.google.com/present/view?id=dkx3qtm_22dxsrgcf4 "Viewport and Media Queries - The Complete Idiot's Guide"). You can find out more in [the Apple developer docs](http://j.mp/mobileviewport). HTML5 Boilerplate comes with a simple setup that strikes a good balance for general use cases. ```html ``` ## Favicons and Touch Icon The shortcut icons should be put in the root directory of your site. HTML5 Boilerplate comes with a default set of icons (include favicon and one Apple Touch Icon) that you can use as a baseline to create your own. Please refer to the more detailed description in the [Extend section](extend.md) of these docs. ## Modernizr HTML5 Boilerplate uses a custom build of Modernizr. [Modernizr](http://modernizr.com) is a JavaScript library which adds classes to the `html` element based on the results of feature test and which ensures that all browsers can make use of HTML5 elements (as it includes the HTML5 Shiv). This allows you to target parts of your CSS and JavaScript based on the features supported by a browser. In general, in order to keep page load times to a minimum, it's best to call any JavaScript at the end of the page because if a script is slow to load from an external server it may cause the whole page to hang. That said, the Modernizr script *needs* to run *before* the browser begins rendering the page, so that browsers lacking support for some of the new HTML5 elements are able to handle them properly. Therefore the Modernizr script is the only JavaScript file synchronously loaded at the top of the document. ## The content area The central part of the boilerplate template is pretty much empty. This is intentional, in order to make the boilerplate suitable for both web page and web app development. ### Google Chrome Frame The main content area of the boilerplate includes a prompt to install Chrome Frame (which no longer requires administrative rights) for users of IE 6. If you intended to support IE 6, then you should remove the snippet of code. ### Google CDN for jQuery The Google CDN version of the jQuery JavaScript library is referenced towards the bottom of the page using a protocol-independent path (read more about this in the [FAQ](faq.md)). A local fallback of jQuery is included for rare instances when the CDN version might not be available, and to facilitate offline development. Regardless of which JavaScript library you choose to use, it is well worth the time and effort to look up and reference the Google CDN (Content Delivery Network) version. Your users may already have this version cached in their browsers, and Google's CDN is likely to deliver the asset faster than your server. ### Google Analytics Tracking Code Finally, an optimized version of the latest Google Analytics tracking code is included. Google recommends that this script be placed at the top of the page. Factors to consider: if you place this script at the top of the page, you’ll be able to count users who don’t fully load the page, and you’ll incur the max number of simultaneous connections of the browser. Further information: * [Optimizing the asynchronous Google Analytics snippet](http://mathiasbynens.be/notes/async-analytics-snippet). * [Tracking Site Activity - Google Analytics](http://code.google.com/apis/analytics/docs/tracking/asyncTracking.html). Alpines Web Template Features Posts Contact Hello, Welcome to Alpines Alpines is free responsive web template for everyone. You can download, edit and use this mobile layout from template mo . Please tell your friends about our website. Thank you. Login Sign Up About Icons You can change icons by Font Awesome Version 4 guidelines. for this download icon. Read Documents Mauris blandit lorem ac dui gravida, vitae mollis magna auctor. Quisque eget mollis risus, eget maximus ligula. Responsive Design Curabitur eleifend velit non est feugiat laoreet. Praesent egestas diam a arcu interdum rhoncus. Curabitur at interdum sapien. Mobile Ready Vestibulum elementum nisi et eleifend pellentesque. Mauris ornare lacinia eleifend. Nam porta tristique mauris vel cursus. Vestibulum elementum nisi et eleifend pellentesque Aliquam non dictum tellus. Morbi ornare, augue sed scelerisque efficitur, elit est rhoncus lacus, in lobortis velit justo ut nunc. Photos by Unsplash Be Happy and Healthy City Capture Nullam bibendum lacus tellus, sit amet suscipit ligula laoreet vitae. Sed est neque, mollis vel tincidunt. Be Kind and Helpful City Capture Nullam bibendum lacus tellus, sit amet suscipit ligula laoreet vitae. Sed est neque, mollis vel tincidunt. Be Adaptive and Flexible City Capture Nullam bibendum lacus tellus, sit amet suscipit ligula laoreet vitae. Sed est neque, mollis vel tincidunt. Be Quick and Easy City Capture Nullam bibendum lacus tellus, sit amet suscipit ligula laoreet vitae. Sed est neque, mollis vel tincidunt. Stay In Touch Fusce congue nisl euismod accumsan mollis. Pellentesque tristique convallis odio. Feel free to send us a message about anything! Go to Top Copyright © 2084 Your Company Name [HTML5 Boilerplate homepage](http://html5boilerplate.com) | [Documentation table of contents](TOC.md) # Miscellaneous ## .gitignore HTML5 Boilerplate includes a basic project-level `.gitignore`. This should primarily be used to avoid certain project-level files and directories from being kept under source control. Different development-environments will benefit from different collections of ignores. OS-specific and editor-specific files should be ignored using a "global ignore" that applies to all repositories on your system. For example, add the following to your `~/.gitconfig`, where the `.gitignore` in your HOME directory contains the files and directories you'd like to globally ignore: ```gitignore [core] excludesfile = ~/.gitignore ``` * More on global ignores: http://help.github.com/ignore-files/ * Comprehensive set of ignores on GitHub: https://github.com/github/gitignore [HTML5 Boilerplate homepage](http://html5boilerplate.com) # HTML5 Boilerplate documentation: ## Getting started * [Usage](usage.md) — Overview of the project contents. * [FAQ](faq.md) — Frequently asked questions, along with their answers. ## The core of HTML5 Boilerplate * [HTML](html.md) — A guide to the default HTML. * [CSS](css.md) — A guide to the default CSS. * [JavaScript](js.md) — A guide to the default JavaScript. * [.htaccess](https://github.com/h5bp/server-configs-apache/tree/master/doc) — All about the Apache web server configs (also see our [alternative server configs](https://github.com/h5bp/server-configs/blob/master/README.md)). * [crossdomain.xml](crossdomain.md) — An introduction to making use of crossdomain requests. * [Everything else](misc.md). ## Development * [Extending and customizing HTML5 Boilerplate](extend.md) — Going further with the boilerplate. ## Related projects HTML5 Boilerplate has several related projects to help improve the performance of your site/app in various production environments. * [Server configs](https://github.com/h5bp/server-configs) — Configs for different servers. * [Node build script](https://github.com/h5bp/node-build-script) — A feature-rich [grunt](https://github.com/gruntjs/grunt) plugin. * [Ant build script](https://github.com/h5bp/ant-build-script) — The original HTML5 Boilerplate build script.