CSS Reset, default styles for common elements

后端 未结 11 2471
情歌与酒
情歌与酒 2020-12-04 17:44

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 e

相关标签:
11条回答
  • 2020-12-04 18:00

    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/

    0 讨论(0)
  • 2020-12-04 18:01

    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.

    0 讨论(0)
  • 2020-12-04 18:03

    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.

    0 讨论(0)
  • 2020-12-04 18:04

    "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.

    0 讨论(0)
  • 2020-12-04 18:05

    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.

    0 讨论(0)
  • 2020-12-04 18:08

    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.

    0 讨论(0)
提交回复
热议问题