ALT_IMG

Tutorials

Featuring short lessons and techniques, covering languages viz. PHP, MySQL, CSS, HTML, JavaScript, Java. The latest methods of developing web applications and basic tutorials of Java technology. You'll find free codes available in the post added with some video tutorials wherever applicable. Readmore...

ALT_IMG

How-To's

There went a rumour about the announcement of the Sony Xperia S and also we have seen some leaked photos of the model many time before. The latest leak photos had Sony Ericsson logo wearing on it but this final product image from CES has a Sony logo on the top Readmore..

Alt img

Tips and Tricks

Sony announces its very first mobile phone ‘Sony Xperia Ion’ in 10 years after it is being seperated from Ericsson at the CES 2012. Now the new products and devices is back with its brand logo of Sony instead of Sony Ericsson. is the first operator to have a Sony phone in the assortment Readmore...

ALT_IMG

Hacking Tricks

In the past few months we saw so many ultrabooks budding up in the electronic market. The Apple’s trendy MacBook Air gave the PC makers a cause to be anxious, since it is obvious that these thin-and-light laptops seems to be in a tough competiton with them. In general, Ultrabooks are the small, light, powerful Readmore...

ALT_IMG

Gadgets

The minute you get your hands on the Droid Xyboard, it is clear that this is a higher-caliber Android tablet while comparing with almost everything else available today. The tablet is sleek, properly balanced and felt comfortable in our hands. A completely new look, significantly enhanced performance and Readmore...

ALT_IMG

Internet Tweaks

There went a rumour about the announcement of the Sony Xperia S and also we have seen some leaked photos of the model many time before. The latest leak photos had Sony Ericsson logo wearing on it but this final product image from CES has a Sony logo on the top Readmore..

ALT_IMG

Tech News

There went a rumour about the announcement of the Sony Xperia S and also we have seen some leaked photos of the model many time before. The latest leak photos had Sony Ericsson logo wearing on it but this final product image from CES has a Sony logo on the top Readmore..

ALT_IMG

Downloads

There went a rumour about the announcement of the Sony Xperia S and also we have seen some leaked photos of the model many time before. The latest leak photos had Sony Ericsson logo wearing on it but this final product image from CES has a Sony logo on the top Readmore..

Showing posts with label Resetting styles with CSS reset. Show all posts
Showing posts with label Resetting styles with CSS reset. Show all posts
Sunday, 9 September 2012

CSS Tip: Resetting Your Styles with CSS Reset

0 comments



Resetting your styles, commonly referred to as CSS Reset or Reset CSS is the process of resetting (or more accurately – setting) the styles of all elements to a baseline value so that you avoid cross-browser differences due to their built-in default style settings. By resetting your styles, you avoid defaulting to the browser’s built-in styles, which differs from browser to browser.


CSS Reset avoids browser inconsistencies

For example, say you use an anchor tag <a> in your HTML document. Usually, browsers like Internet Explorer and Firefox will render it as blue and underlined.

But five years from now, someone decides to release a new browser (let’s call it UltraBrowser) and they decide that they don’t like blue, underlined links – so instead they set the default style of <a> tags to red and boldfaced. If you always set a baseline value for your <a> elements, then you’re guaranteed that it will always be the same, regardless of what UltraBrowser thinks <a> elements should look like.


A simple example

Example 1: How paragraph tags are rendered by default.

In Example 1, I’ve placed three unstyled paragraphs <p> inside a container <div> (I gave the container div a blue background and orange border to highlight the difference).
By default, in Firefox, you’ll see that there’s a space in between the top of the first paragraph and the top of the container div, and a space between the bottom of the last paragraph and the bottom of the container div.

By default, these spaces don’t exist in Internet Explorer.

So which browser is right, Firefox or IE? It doesn’t matter. What does matter is that the spacing in between your paragraphs and other elements will look dissimilar if you don’t set a style for a paragraph’s margin and padding.

Of course that’s a rather simplified example. In practice, CSS Reset is important in removing inconsistent margins, paddings, line-heights, and other attributes that can cause your web pages to look differently across various browsers.

So that’s the basic theory of resetting your styles which just means you set your style rules for all elements to avoid having the browser do it for you.

The below CSS Reset code has been taken from HTML5Doctor. It’s recommended to use a CSS reset for consistency.

/* 
html5doctor.com Reset Stylesheet
v1.6.1
Last Updated: 2010-09-17
Author: Richard Clark - http://richclarkdesign.com 
Twitter: @rich_clark
*/

html, body, div, span, object, iframe,
h1, h2, h3, 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, canvas, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section, summary,
time, mark, audio, video {
    margin:0;
    padding:0;
    border:0;
    outline:0;
    font-size:100%;
    vertical-align:baseline;
    background:transparent;
}

body {
    line-height:1;
}

article,aside,details,figcaption,figure,
footer,header,hgroup,menu,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;
}

/* change colours to suit your needs */
ins {
    background-color:#ff9;
    color:#000;
    text-decoration:none;
}

/* change colours to suit your needs */
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;
    cursor:help;
}

table {
    border-collapse:collapse;
    border-spacing:0;
}

/* change border colour to suit your needs */
hr {
    display:block;
    height:1px;
    border:0;   
    border-top:1px solid #cccccc;
    margin:1em 0;
    padding:0;
}

input, select {
    vertical-align:middle;
}



Continue reading →