tags:

views:

6470

answers:

8

Hi,

After applying a CSS reset, I want to get back to 'normal' behavior for html elements like: p, h1..h6, strong, ul and li.

Now when I say normal I mean e.g. the p element adds spacing or a carriage return like result when used, or the size of the font and boldness for a h1 tag, along with the spacing.

I realize it is totally up to me how I want to set the style, but I want to get back to normal behavior for some of the more commen elements (at least as a starting point that I can tweak later on).

+4  A: 

You mean like:

* {
    padding: 0;
    margin: 0;
}

h1, h2, h3, h4, h5, h6, p, blockquote, form, label, ul, ol, dl, fieldset, address {
    margin-bottom: 1em;
}

?

Actually, sorry I mis-read your question, you're after something more like Eric Meyer's total reset @ http://meyerweb.com/eric/tools/css/reset/

da5id
no I don't need the actual reset, just wanted to get the normal behavior which I guess is just the 1em on the margin-bottom thanks!
public static
if you want to be really pedantic/safe, you should re-specify things like font-sizing/bold/etc for elements too i guess...
da5id
+14  A: 

YUI provides a base CSS file that will give consistent styles across all 'A-grade' browsers. They also provide a CSS reset file, so you could use that as well, but you say you've already reset the CSS. For further details go to the YUI website. This is what I've been using and it works really well.

Steven Oxley
I wasn't aware of that - thanks for the tip :)
da5id
which are the "A-grade" browsers? :D
CrazyJugglerDrummer
Yahoo defines that here: http://developer.yahoo.com/yui/articles/gbs/
Steven Oxley
+7  A: 

One of the rules in applying CSS styles is "last in wins." This means if your CSS reset styles set elements to margin:0; padding:0 you can then override these rules by declaring your desired values for the same elements afterwards.

You can do this in the same file (YUI offers a one-liner reset I think so I sometimes include it as the first line in my CSS file) or in a separate file that appears after the reset CSS <link/> tag.

I think by normal behavior you mean "the defaults for my favorite browser." Your building up CSS rules for these elements is a part of the reset exercise.

Now you might want to look into Blueprint CSS or other grid frameworks. These grid frameworks almost always first reset styles to nothing, then build up the typography for common elements, etc. This could save you some time and effort.

Carl Camera
I think that is what YUI base/fonts/grids/reset does...
public static
Agreed. The YUI Base Reset builds up common element styles after applying the YUI CSS Reset to neutralize differences. Together they are a great tool in any web developers toolbox.
Carl Camera
+2  A: 

If you want to see the css defaults for firefox, look for a file called 'html.css' in the distribution (there should be some other useful css files in the same directory). You could pick out the rules that you want, and apply them after a reset.

Also, the CSS2 standard has a sample stylesheet for html 4.

Daniel James
A: 

"After applying a CSS reset, I want to get back to 'normal' behavior for html elements..."

If you've applied a reset, you would then have to add the rules for what you believe to be normal behavior. Since normal behavior varies from browser to browser this question is something of a non sequitur. I like @da5id's answer - use one of the many available resets and tweak it to suit your needs.

Traingamer
+3  A: 

Check out YUI (Yahoo's open source user interface conventions).

They have a base stylesheet that undoes their own reset css. They dont actaully recommend you use it in production - since its counter productive but definitely might be worth checking out the file to get relevant snippets for what you want to 'undo'.

I recommend you watch the 40 minute talk to get up to speed.

Heres a short snippet of their base.css file :

ol li {
    /*giving OL's LIs generated numbers*/
    list-style: decimal outside; 
}
ul li {
    /*giving UL's LIs generated disc markers*/
    list-style: disc outside;
}
dl dd {
    /*giving UL's LIs generated numbers*/
    margin-left:1em;
}
th,td {
    /*borders and padding to make the table readable*/
    border:1px solid #000;
    padding:.5em;
}
th {
    /*distinguishing table headers from data cells*/
    font-weight:bold;
    text-align:center;
}

Download the full stylesheets below or read full documentation.

Yahoo reset css | Yahoo base (undo) reset css

Simon_Weaver
YUI now has version 3 - so these links are probably out of date
Simon_Weaver
+2  A: 

I'm personally a big fan of BlueprintCSS. It resets styles across browsers and provides some really convenient defaults (that are what you want 90% of the time). It also provides a layout grid, but you don't have to use that if you don't need it.

zenazn
@zenazn is it easy/possible to tell from blueprint css how to undo specific things. for instance how to restore LI discs, or default padding for a page. obviously its easy to set these things, but hes looking for how to get back to things close to the original defaults.
Simon_Weaver
Blueprint CSS provides it's own set of (rather sane) defaults that are similar to what browsers provide by default. For instance, LI disks look normal, the space around H#s and Ps look normal, etc.
zenazn
+1  A: 

Normal behaviour for WebKit h1:

h1 {
    display: block;
    font-size: 2em;
    margin: .67__qem 0 .67em 0;
    font-weight: bold
}

Normal behaviour for Gecko h1:

h1 {
    display: block;
    font-size: 2em;
    font-weight: bold;
    margin: .67em 0;
}

The rest of the elements should be there if you search the files.

robertc