20 Essential Snippets for HTML5 Boilerplate

- - CSS
20 Essential Snippets for HTML5 Boilerplate

20 Essential Snippets for HTML5 Boilerplate

20 Essential Snippets for HTML5 Boilerplate.I recently, as many web designers and developers can have, became privy to a superb useful resource prepare by means of web developer, Paul Irish, and Divya Manian. HTML5 Boilerplate, as they have got named it, is a powerful setting out point for any website or internet software.

As Paul Irish describes it: “It’s essentially an amazing starting template of html and css and a folder shape that works., however baked into it’s miles years of exceptional practices from the front-end improvement experts.”

HTML

we will start off by checking out some of the html snippets used in the aid. All of those are snippets of code that might not necessarily be simplest html, however will truly be located on your html files if used.

Favicon and Apple icons

The favicon is pretty much normality those day. the interesting bit here is the apple-touch-icon that’s used if you save a bookmark to your property screen on an apple contact device such as an iPad or iPhone. apparently sufficient, android additionally helps its usage.

As far as i will tell, the apple-contact-icon size is 60px by 60px. because the comment says, if your icons are inside the root of your domain, those links aren’t required.

!-- Place favicon.ico and apple-touch-icon.png in the root of your domain and delete these references

Faster Page Load Hack

This empty conditional comment hack is used to essentially growth overall performance of your web page. while conditional remarks are used on your website online, as an example, for an ie6 conditional stylesheet, it’ll block similarly downloads till the css files are completely downloaded, therefore growing load time.

To solve this difficulty, an empty conditional comment, like below, is used earlier than any css is loaded within the document, and the trouble can be solved! For further analyzing, check out this article.

X-UA-Compatible

internet Explorer has many rendering engines ready for use. What this line of code essentially does is force IE to apply the most up to date rendering engine that it has available, in order that your pages will render as well as viable. It then goes on to talk about Chrome frame. Chrome frame is a plugin for IE6, 7, and eight which brings all of the rendering, and js energy of Google Chrome to IE.

If the consumer has it hooked up, we render our web page the use of it. For more records on Chrome frame, and the way you could even activate users with out it to install it, take a look at right here.

Conditional body tag

This snippet is a Paul Irish unique, and permits you to target IE browsers specifically while not having to add in an additional http request with some other separate stylesheet.

basically, relying at the IE browser that the person is using, a category is introduced to the frame tag. If the user isn’t the usage of IE, then a classless body tag is used. This allows you to target precise browsers for your css without having to apply css hacks, or further stylesheets. For in addition reading, take a look at out the authentic article on this.

JQuery loading fallback

A sizable majority of sites nowadays employ the jQuery JavaScript library. A enormous majority additionally employ Google’s hosted version of the library for faster loading velocity’s, and higher pass website online caching. however, what if there may be ever a problem and jQuery isn’t always loaded from Google? properly here is your backup.

What it essentially does is check if jQuery is loaded from Google. If not, then we load it regionally from our own model of jQuery.

Optimized Google Analytics

Google Analytics is a totally famous device for monitoring your website’s user behaviour, and visits.

this is truely an optimized version of Google’s asynchronous monitoring snippet. To research what has been optimized, and why it is faster than Google’s personal model, read the article right here.



 var _gaq = [['_setAccount', 'UA-XXXXX-X'], ['_trackPageview']];
 (function(d, t) {
  var g = d.createElement(t),
      s = d.getElementsByTagName(t)[0];
  g.async = true;
  g.src = Google Analytics
.js';
  s.parentNode.insertBefore(g, s);
 })(document, 'script');

CSS

moving on into CSS, this is in which the great majority of super snippets care to be found. Don’t be do away with by means of some of the one-liners; they may be just as useful and superb as a number of the larger snippets to be observed.

HTML5 Ready Reset

lots of you may have used Eric Meyer’s css reset earlier than now. it is blanketed in lots of frameworks and so forth, like 960.gs. this is a made over version of that reset, that brings it into the present with complete support for html5. It units all the new structural tags as block stage, and resets all their default styling as predicted.

/*   maniwebify.com Reset Stylesheet (Eric Meyer's Reset Reloaded + HTML5 baseline)  v1.4 2009-07-27 | Authors: Eric Meyer & Richard Clark  html5docter/html-5-reset-stylesheet/*/
html, body, div, span, object, iframe,
h1, h2, h2, h4, h5, h6, p, blockquote, pre,
abbr, address, cite, code,
del, dfn, em, img, ins, kbd, q, samp,
small, strong, sub, sup, var,
b, i,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, figure, footer, header, hgroup, menu, nav, section, menu,
time, mark, audio, video {
margin:0;
padding:0;
border:0;
outline:0;
font-size:100%;
vertical-align:baseline;
background:transparent;
}

article, aside, figure, footer, header,
hgroup, nav, section { display:block; }

nav ul { list-style:none; }

blockquote, q { quotes:none; }

blockquote:before, blockquote:after,
q:before, q:after { content:''; content:none; }

a { margin:0; padding:0; font-size:100%; vertical-align:baseline; background:transparent; }

ins { background-color:#ff9; color:#000; text-decoration:none; }

mark { background-color:#ff9; color:#000; font-style:italic; font-weight:bold; }

del { text-decoration: line-through; }

abbr[title], dfn[title] { border-bottom:1px dotted #000; cursor:help; }

/* tables still need cellspacing="0" in the markup */
table { border-collapse:collapse; border-spacing:0; }

hr { display:block; height:1px; border:0; border-top:1px solid #ccc; margin:1em 0; padding:0; }

input, select { vertical-align:middle; }
/* END RESET CSS */

Font normalization

To remove rendering inconsistencies which could arise among browsers and OS’s whilst rendering fonts in pixels, this snippet allows you to length your fonts in this type of manner that the size and line-peak will stay constant throughout those platforms to your internet site.

you will essentially be placing your font sizes via possibilities that can be determined right here.

/*
fonts.css from the YUI Library: developer.yahoo,com/yui/
Please refer to developer.yahoo,com/yui/fonts/ for font sizing percentages
*/
body { font:13px sans-serif; *font-size:small; *font:x-small; line-height:1.22; }
table { font-size:inherit; font:100%; }
select, input, textarea { font:99% sans-serif; }

Webkit font smoothing

this is anti-aliasing for webkit browsers, unluckily most effective in Mac OSX. It basically makes your text render higher, and make it extra readable, with out all the text thinning hacks that we’ve got visible within the beyond. For similarly reading test out Tim Van Damme’s article on this.

/* maxvoltar,com/archive/-webkit-font-smoothing */
html { -webkit-font-smoothing: antialiased; }

Force Scrollbar

sometimes, pages may be shorter than the browser view-port, and when you load a page at the same website that has longer content material and makes use of a scrollbar, content can jump facet to facet. by means of forcing a scrollbar no matter the height of our content, we stop this small, but annoying issue.

html { overflow-y: scroll; }

Formatting quoted code

This snippet simply makes the text wrap when it reaches the walls of its container, in this case, the pre tag, whilst still preserving line breaks and white space cross browser.

pre {
padding: 15px;
white-space: pre; /* CSS2 */
white-space: pre-wrap; /* CSS 2.1 */
white-space: pre-line; /* CSS 3 (and 2.1 as well, actually) */
word-wrap: break-word; /* IE */
}

Aligning Labels

Alignment of labels with their relevant inputs can be a horrible task to achieve in older browsers. This snippets solves that for us by making it consistent across browsers!

/* align checkboxes, radios, text inputs with their label */
input[type="radio"] { vertical-align: text-bottom; }
input[type="checkbox"] { vertical-align: bottom; *vertical-align: baseline; }
.ie6 input { vertical-align: text-bottom; }

Click Able inputs

For some purpose, most browsers don’t apply a pointer cursor to some clickable input’s by default to permit the user now that this item is clickable, so we clear up this by way of doing it ourselves.

/* hand cursor on clickable input elements */
label, input[type=button], input[type=submit], button { cursor: pointer; }

Screen reader access

This snippet basically gives us the best of both worlds, allowing the best usability when it comes to link outlines for both screen readers tabbing through links, and mouse users.

a:hover, a:active { outline: none; }

a, a:active, a:visited { color:#607890; }
a:hover { color:#036; }

IE7 image resizing

Ie7 by default uses an image resizing algorithm that means that scaled down images can look far from awesome. To solve this, we simply enable a much better resizing algorithm that is available in Ie7 that produces results similar to what you’d expect from most image editing software.

/* bicubic resizing for non-native sized IMG:
code.flick,com/blog/2008/11/12/on-ui-quality-the-little-things-client-side-image-resizing/ */
.ie7 img { -ms-interpolation-mode: bicubic; }

Print styles

Any decent site should be print ready, as even though we live in a technology driven time, people still like to have a hard copy of some information. This snippet firstly uses a css media declaration, allowing you to include this in your main stylesheet, and not having to place another link in the head of your document.

This benefits load time, as even when the page inst being printed, a browser will always download that extra css file, generating an extra http request. The snippet then goes on to include some useful print styles such as printing our link urls, and so on.

/*
* print styles
* inlined to avoid required HTTP connection www.phpied,com/delay-loading-your-print-css/
*/
@media print {
* { background: transparent !important; color: #444 !important; text-shadow: none; }
  a, a:visited { color: #444 !important; text-decoration: underline; }
  a:after { content: " (" attr(href) ")"; }
  abbr:after { content: " (" attr(title) ")"; }    .ir a:after { content: ""; }  /* Don't show links for images */    pre, blockquote { border: 1px solid #999; page-break-inside: avoid; }    img { page-break-inside: avoid; }
  @page { margin: 0.5cm; }
  p, h2, h2 { orphans: 3; widows: 3; }
  h2, h2{ page-break-after: avoid; }
}

Device Orientation

These are just two css media queries you may want to use for your website development. With lots of smart-phones, and tablets being able to orientate their screens from landscape to portrait, you may want to include different styles for each. This is how you would go about achieving this.

@media all and (orientation:portrait) {
/* Style adjustments for portrait mode goes here */
}

@media all and (orientation:landscape) {
/* Style adjustments for landscape mode goes here */
}

.htaccess

One thing that this starting point template does come with that other starting point templates generally don’t, is server sided files. Check out these awesome .htaccess snippets that can easily improve your site.

X-UA-Compatible Server sided

This is the same as the html version mentioned above, forcing the latest rendering engine in IE, and Chrome Frame if it exists. The benefit of including this in your .htaccess file is that it saves you having to declare this in the head of each and every html document you produce.

 
    BrowserMatch MSIE ie
    Header set X-UA-Compatible "IE=Edge,chrome=1" env=ie
  IfModule>
IfModule>

Gzip compression

Gzip compression allows us to significantly reduce out file sizes. This .htaccess snippet does the gzipping for us.

# gzip compression.

  # html, xml, css, and js:
  AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript text/javascript application/javascript application/json
  # webfonts and svg:
  
    SetOutputFilter DEFLATE
  

Expiry date for cache file types

When we cache our files on the user’s machine, we may want to specify how long they remain there, depending on how often we change them ourselves. This snippet provides basic times for common file types, some of which you may wish to change for your own site.

# these are pretty far-future expires headers
# they assume you control versioning with cachebusting query params like
#   
# additionally, consider that outdated proxies may miscache
#   www.stevesouders,com/blog/2008/08/23/revving-filenames-dont-use-querystring/
# if you don't use filenames to version, lower the css and js to something like
#   "access plus 1 week" or so

  Header set cache-control: public
  ExpiresActive on

  # Perhaps better to white list expires rules? Perhaps.
  ExpiresDefault                          "access plus 1 month"
  # cache.manifest needs re-requests in FF 3.6 (thx Remy ~Introducing HTML5)
  ExpiresByType text/cache-manifest       "access plus 0 seconds"
  # your document html
  ExpiresByType text/html                  "access"
  # rss feed
  ExpiresByType application/rss+xml       "access plus 1 hour"
  # favicon (cannot be renamed)
  ExpiresByType image/vnd.microsoft.icon  "access plus 1 week"
  # media: images, video, audio
  ExpiresByType image/png                 "access plus 1 month"
  ExpiresByType image/jpg                 "access plus 1 month"
  ExpiresByType image/jpeg                "access plus 1 month"
  ExpiresByType video/ogg                 "access plus 1 month"
  ExpiresByType audio/ogg                 "access plus 1 month"
  ExpiresByType video/mp4                 "access plus 1 month"
  # webfonts
  ExpiresByType font/ttf                  "access plus 1 month"
  ExpiresByType font/woff                 "access plus 1 month"
  ExpiresByType image/svg+xml             "access plus 1 month"
  # css and javascript
  ExpiresByType text/css                  "access plus 1 month"
  ExpiresByType application/javascript    "access plus 1 month"
  ExpiresByType text/javascript           "access plus 1 month"


# Since we're sending far-future expires, we don't need ETags for
# static content.
#   developer.yahoo,com/performance/rules.html
#etags
FileETag None

Further Thoughts

I strongly suggest you go check out their website. It is a fantastic resource that houses all of these snippets and more, that I am sure you will find useful.

how to make chicken handi

how to make chicken handi

how to make chicken handi

how to make chicken handi
how to make chicken handi

how to make chicken handi
how to make chicken handi
maniwebify

how to make chicken handi


Hi..! Here Your Favorite Arslan Malik the Blogger..! Trust Me..! I Am Very Interesting Men In The Whole World...9.9% Of Great Bloggers Are Not Awesome On Day 1. Their Awesomeness Is The Accumulation Of The Value They Create Over Time.