10 replies [Last post]
nizzleworkz
nizzleworkz's picture
User offline. Last seen 1 year 46 weeks ago. Offline
newbie
Timezone: GMT-7
Joined: 2010-03-15
Posts: 1
Points: 2

Why is:

* { margin: 0; padding: 0;}

bad practice? I've used this method for years. I am told a 'reset' is better. Why is this better?

Any answers or articles would be appreciated

Verschwindende
Verschwindende's picture
User offline. Last seen 6 days 11 hours ago. Offline
rank Guru
Guru
Timezone: GMT-5
Joined: 2009-10-09
Posts: 2037
Points: 2256

I wouldn't say reset is

I wouldn't say reset is better because it's pretty much just as unnecessary. Using * is sort of like using a jackhammer and reset is like using a ball peen hammer. Unfortunately, the tool for the job is a scalpel.

My advice, with a money back guarantee, use neither.

yet again.

Hugo
Hugo's picture
User offline. Last seen 15 hours 25 min ago. Offline
rank Moderator
Moderator
Joined: 2004-06-06
Posts: 15096
Points: 2191

We went into this at length

We went into this at length in a forum thread so have a search for that for a few answers.

Some of us around doing this years ago started to use the universal selector to zero margins and padding this was long before it was widely disseminated and very long before the dire and dreadful notion of the reset.css file that one now sees cropping up in bloody theme files here there and everywhere came along.

If you understand what you are doing with that universal reset as you describe then continue it does no real harm (what was dumb though is some bright spark thinking to add border:none to the properties which just wrecks form elements with no way back), the sensible approach is to then set defaults for elements to use a a paragraph without margins is never going to work; but then again if setting defaults or global values to generic elements was there a point to zeroing them in the first place?

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

Verschwindende
Verschwindende's picture
User offline. Last seen 6 days 11 hours ago. Offline
rank Guru
Guru
Timezone: GMT-5
Joined: 2009-10-09
Posts: 2037
Points: 2256

Hugo wrote: ... but then

Hugo wrote:

... but then again if setting defaults or global values to generic elements was there a point to zeroing them in the first place?

That's the big issue, isn't it? There's just no point to zeroing and then redefining things. Why not just skip the first step?

I do find the * useful when zeroing inside a section or table. Like this:

.noTableStyle * {
	border-collapse: collapse;
	border: none;
	overflow: visible;
	margin: 0;
	padding: 0;
}
This helps when using some third party scripts that blow out when used with my styling for other sections.

yet again.

Hugo
Hugo's picture
User offline. Last seen 15 hours 25 min ago. Offline
rank Moderator
Moderator
Joined: 2004-06-06
Posts: 15096
Points: 2191

Ah not so fast there was a

Ah not so fast there was a reason at least then their was. UL elements depending on browser either padded or margined so one would have cleared both out regardless and then simply re-stated one or the other on a generic UL, it's a pretty thin reason though Smile

Simply don't do it clearing these properties also means that you have to restate them or rather forget to thinking everything is cool, realise you are working with a dynamic site/CMS and/or worse an editor such as tinymc and that the user wanted a bullet list, oops no bullets! wonder why?

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

Hugo
Hugo's picture
User offline. Last seen 15 hours 25 min ago. Offline
rank Moderator
Moderator
Joined: 2004-06-06
Posts: 15096
Points: 2191

Point is that as Versh

Point is that as Versh demonstrates he makes a considered decision to state some defaults and that is what we do we should know what we are doing and have full control and knowledge of when and where we need to do this.

The reset.css is a ...ing abomination it's a trap, a fix for those that simply really don't know what they are doing and as such it's pure evil Crazy anything that seeks to compensate for the users lack of knowledge is by definition simply BAD, EVIL, CORRUPT.

I come across the dam thing and want to rip it out of a template however the so called developers that have blindly coded their styles with this abomination in place are trapped by it, remove it and everything falls apart, and you would have to start going through every property ruleset setting things to rights.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

gary.turner
gary.turner's picture
User offline. Last seen 2 hours 42 min ago. Offline
rank Moderator
Moderator
Timezone: GMT-6
Joined: 2004-06-25
Posts: 7696
Points: 1512

One of the discussions Hugo

One of the discussions Hugo refers to is here. Here is another.

I wouldn't go as far as Hugo, though I have considered it, but resets are a redundant waste of time, having no socially redeeming value. That pretty well matches Los Supremos definition of pornography, but not of evil. Tongue

cheers,

gary

Unplanned code results in a tangled wad of brain-cramping confusion.

There are enough html & css demos and tutorials to be interesting. Please visit.

Hugo
Hugo's picture
User offline. Last seen 15 hours 25 min ago. Offline
rank Moderator
Moderator
Joined: 2004-06-06
Posts: 15096
Points: 2191

Gary is wrong. While all good

Gary is wrong. While all good Garys stood about evil flourished.

Frontend coding will be reduced to a set number of stock files, select the ones you want and away you go. It's a conspiracy set in motion by programmers fear of anything that isn't reducible to a rigid structure with absolute rules.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

CupidsToejam
CupidsToejam's picture
User offline. Last seen 2 weeks 1 day ago. Offline
rank Guru
Guru
Timezone: GMT-6
Joined: 2008-08-15
Posts: 2634
Points: 1552

Hugo wrote: We went into this

Hugo wrote:

We went into this at length in a forum thread so have a search for that for a few answers.

I remember that war. It was quite fun and entertaining!


First basic few steps in building a webpage
1. Gather and collect content.
2. Organize the content into meaningful semantic valid HTML
3. Design the prototype
4. Style using CSS

http://www.pixelbehavior.com

Chris..S
Chris..S's picture
User offline. Last seen 21 hours 22 min ago. Offline
rank Moderator
Moderator
Joined: 2005-02-22
Posts: 6075
Points: 167

Hmm, it seems all the replies

Hmm, it seems all the replies have missed the points - except maybe in Gary's links which I am too lazy to follow Smile

Universal reset * {margin: 0; padding: 0;} is considered bad because it messes up with the default values on form controls. Its often much easier to leave form controls at browser/OS defaults. If your site doesn't have any forms, the universal reset is just fine.

The reset css is a development tool. It really shouldn't make it into your final site. Its a way of ensuring that any styles applied to elements are YOUR styles not those of the browser. The thinking being, that browser styles are not guaranteed to be identical. So if you come up against a browser you've not built/tested against, if all styles are your styles and the browser is standards compliant, your site will be just fine.

Hugo
Hugo's picture
User offline. Last seen 15 hours 25 min ago. Offline
rank Moderator
Moderator
Joined: 2004-06-06
Posts: 15096
Points: 2191

No Chris ALL replies haven't

No Chris ALL replies haven't missed the point Crazy Smile

The point is not specifics, note I mention that the fool that added border:0; to the universal reset needed a slap across the face with a wet fish, Zero padding and margins messing up forms, yes but then again they mess up paragraphs equally too.

You might think reset.css is a development tool and that it shouldn't make it to production but the reverse is true actually the flipping thing DOES make it to production with increasing frequency.

Anyhow as you said the links you didn't follow are where all this was discussed ad nauseam, pointless rehashing it all in potted form.

Best thing I've found is to start to try and not care anymore *shrug*

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me