Jump to content

Recommended Posts

Posted

I am looking at rebuilding one of my sites again, as it has been commented that people can't find things on the site, so I am looking to make the navigation simpler.

On having a look around at various css templates for ideas on what my work, I found one that could be adapted for my needs.

The question is how does the following work * { padding: 0; margin: 0; } at the top of the style sheet. I can see what it does on the resulting page, but I don't understand how.

Posted (edited)

I use

*{padding: 0; margin: 0;}

on all my CSS - various browsers have various default settings for various properties, and setting them all to 0 first and then adding the exact measurement you want later, prevents many cross-browser inconsistencies.

 

However, the opinions are divided - I find the above is simple and fast and takes care of everything at once, others belief it to be more efficient to only set to zero those properties that could be affected like so:

body, address, blockquote, dl, ol, ul, li, fieldset, form,
h1, h2, h3, h4, h5, h6, p, pre {
margin:0;
padding:0;
}

Edited by Andrea
Posted

The star is just a short hand way of way of selecting every element on the page and applying a margin and padding of zero to them.

 

The star is just a selector, like any other:

 

*{
   margin:0;
   padding:0
}

div#content{
   margin:0; /*This div already has a margin of zero due to the rule above*/
}

 

This is quite a slow process, and there are better ways of reseting CSS - check out the Yahoo reset CSS, for example.

Posted

ok i didnt get somthing.. way should i reset my css?

 

i built a couple of web pages... and i did'nt put any thing to "reset" the css file....

 

so my Q's R-

 

1. what is "reseting CSS"?

2. why should i use it?

Posted

By default certain elements carry a predetermined padding and margin. If you are seeing extra spaces between elements on your page, this could be the culprit. By "resetting" these elements to zero, you have control over placement.

Posted

Just to add to JBall's post, "resetting" the CSS is especially useful to eliminate differences between browsers. Some browsers have different defaults, so if you reset them, it gives you more precise control, and may eliminate inconsistencies.

Posted

ok thnks... i think i got the main idea about that....

 

and i now know that i defently need to use it.

 

so where exectly i put the star "*" with the "reset" peremiters?

Posted
ok thnks... i think i got the main idea about that....

 

and i now know that i defently need to use it.

 

so where exactly i put the star "*" with the "reset" perimeters?

 

Usually you would put that at the start of your CSS file.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...