PDA

View Full Version : Default CSS


timgolding
12-04-2007, 12:29 PM
The other day someone posted an excellent default CSS. That resets everything relative to all browsers. EG setting all margins, borders to 0 etc. I have looked through the forums but had no luck.. Does anyone know about this post or know where I can obtain this CSS document?

Thanks

Arbitrator
12-04-2007, 12:44 PM
The other day someone posted an excellent default CSS. That resets everything relative to all browsers. EG setting all margins, borders to 0 etc. I have looked through the forums but had no luck.. Does anyone know about this post or know where I can obtain this CSS document?Well, if you want to reset everything, you would have to set everything to its default value with a universal selector. For example, you can get all of the default values for the CSS2.1 properties at http://www.w3.org/TR/CSS21/propidx.html in the “Initial” column. Of course, this won’t help you defeat certain defaults, like Internet Explorer’s defaulting of table border colors to a silvery color (since Internet Explorer would need to support the CSS3 Color module (W3C CR) currentColor keyword for that).

Otherwise, you can just reset a select few properties like those that tend to pose problems or are otherwise annoying:

* { margin: 0; padding: 0; }

bazz
12-04-2007, 01:14 PM
you could start your css file with


html, body {
margin : 0;
padding : 0;
border : 0
}


I think the * doesn't work in ie7.

bazz

VIPStephan
12-04-2007, 02:22 PM
I think the * doesn't work in ie7.

Who said that??? The universal selector (*) has been around since the beginning of ti… erm, CSS and is working in all browsers, and there’s no reason why they should have stopped supporting it in IE 7…

It’s the so called “star HTML hack” that is not working anymore. It exploited a bug in IE 6 where the html element had some secret, imaginary, nameless parent element which could be used to apply a style to IE 6 only by typing * html …. Effectively this means “select all html elements that are child of any element”. Since only IE 6 interpreted that the wrong way it’s called an exploit which has been fixed in IE 7.

Capiche? :D

bazz
12-04-2007, 03:16 PM
Good to know. I hadn't grasped that only one of them had been 'fixed' in ie7.


bazz

Excavator
12-04-2007, 04:09 PM
I put this in everything I write:* {
margin: 0;
padding: 0;
border: none;
}

Apostropartheid
12-04-2007, 04:16 PM
I like to put my font family in my * selector, so it generally begins: * {
margin: 0;
padding: 0;
border: none;
outline: none;
font: inherit/inherit Calibri, Verdana, Trebuchet, "Helvetica Neue", sans-serif;
color: #333;
}

Of course, you could do this on html, but...meh, habit.