Web design: CSS defaults:

Soldato
Joined
2 Aug 2004
Posts
8,209
Location
Buckinghamshire
Hi all,

I do abit of web design now, and I use XHTML and CSS and like to produce nice, clean and effective sites.

However, each and everytime I do so - I run into problems sooner or later down the line where the layout does not play ball in one of the browsers, either I.E, Firefox or Opera.

I believe this is down to me not setting a default rule for some elements in my CSS.

For instance I normally set margin, padding and such to 0 but I think there are others which may need to be set - such as line height?

What rules do you apply within your CSS straight away?

Thanks, Mark
 
Code:
*, body, html {
margin: 0;
padding: 0;}

body {
font-size: 62.5%;}

em {
font-style: italic;}

strong {
font-weight: bold;}
The font-sizing is for working with ems cross-browser: http://www.clagnut.com/blog/348/. em/strong because that's what I usually want from em and strong tags, but is not necessarily how they are rendered in user-agents.

Don't recall finding myself running into any other issues related to default values.

Check out Yahoo's reset.css for one take on a base CSS:
Code:
/*
Copyright (c) 2006, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
version: 0.11.3
*/
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,p,blockquote,th,td{margin:0;padding:0;}
table{border-collapse:collapse;border-spacing:0;}
fieldset,img{border:0;}
address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}
ol,ul {list-style:none;}
caption,th {text-align:left;}
h1,h2,h3,h4,h5,h6{font-size:100%;}
q:before,q:after{content:'';}
There's also one for fonts.
 
Back
Top Bottom