Mark H Posted October 14, 2011 Share Posted October 14, 2011 Hi all, I am trying to get into better practices and have written a CSS style sheet for my site that clears and then sets the basic CSS rules. Have I made any great error in this? I would appreciate feedback as I am planning on using this style sheet (adjusted for particular site requirements, on all my sites). Many thanks. The code: @charset "utf-8";/* CSS Document *//* Clear all elements */p, h1, h2, h3, h4, h5, h6 {margin: 0;padding: 0;text-indent: 0;font-size: 100%;font-weight: normal;}div, ul, li {margin: 0;padding: 0;text-indent: 0;}/* clear link defaults */a {margin: 0;padding: 0;text-indent: 0;font-size: 100%;}/* Set site defaults */p {font-size: 12px;margin-top: 5px;margin-bottom:3px;font-weight: normal;}h1 {font-size: 18px;margin-top: 12px;margin-bottom: 10px;margin-left: 8px;font-weight: bold;}h2 {font-size: 14px;margin-top: 6px;margin-bottom: 4px;margin-left: 3px;font-weight: bold;}h3 {font-size: 12px;margin-top: 7px;margin-bottom: 5px;margin-left: 2px;font-weight: bold;}h4 {font-size: 10px;margin: 2px;font-weight: bold;}h5 {font-size: 8px;margin: 1px;font-weight: bold;}h6 {font-size: 6px;font-weight: normal;} Link to comment Share on other sites More sharing options...
thescientist Posted October 14, 2011 Share Posted October 14, 2011 Well, best practices is to always declare a unit size. You could also make judicious use of the universal selector *, to reset common attributes across the board.i.e. *{ margin: 0px; padding: 0px; text-indent: 0px;} to save space, I would consolidate some of your declarations h1{ margin: 18px 0px 10px 8px; /* T, R, B, L */} Link to comment Share on other sites More sharing options...
knystrom18 Posted October 15, 2011 Share Posted October 15, 2011 Have you seen the Myerweb Reset? - http://meyerweb.com/eric/tools/css/reset/ Link to comment Share on other sites More sharing options...
dsonesuk Posted October 15, 2011 Share Posted October 15, 2011 By default header text is already bold This is a reset i use *{padding:0;margin:0;}body{font-family:Verdana, Arial, Helvetica, sans-serif; font-size:62.5%;} /* font-size equivalent to 10px*/p{margin:0.9em 0;}h1, h2, h3, h4, h5, h6{margin:0.9em 0;}h1 {font-size:2em;}h2 {font-size:1.84em;}h3 {font-size:1.68em;}h4{font-size:1.52em;}h5 {font-size:1.36em;}h6 { font-size:1.20em;} Link to comment Share on other sites More sharing options...
Mark H Posted October 18, 2011 Author Share Posted October 18, 2011 Thanks for your feedback guys. I see, though, that whilst you Scientist say to use a unit size, dsonesuk doesn't. Is this a personal preference or is it best to declare a unit size always? Thanks, I have a few additions/adjustments I can make. Link to comment Share on other sites More sharing options...
dsonesuk Posted October 18, 2011 Share Posted October 18, 2011 a unit is not required for zero value, as zero will be the same for whatever unit used px, em, %, pt, so i just use it without. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.