5 CSS Tips for Website Design

Posted on Monday 6th Sep 2010 by Michael Angrave 2 Comments

Website Design CC Tips

Please tip generously!

Every now and then it’s always useful in website design to share a few of the smaller things that make life that little bit easier. Here’s five little tips to ease your CSS worries.

Each and every one of us picks up helpful and practical ways of doing things in your day to day web design life, so i’d like to share with you, few snippets of my experience.

Don’t over use classes

Avoid over-using classes to style common tags, by breaking sections of your site into div id’s and styling tags that sit within this div.

for example…

 #news-column h2 {font-weight:bold;}

Bullet points using background images

Instead of using list-style-image, you could use a non-repeating background on the li, and use padding to declare the required gap. This also means that further lines of text within that particular list item, will also adopt the same padding, giving a nice neat finish. However using this technique, you’ll still have to use the following to remove the default list image.

List-style-type:none;

Absolute positioning

The simple rule of absolute positioning is that the container div must be position:relative, and the div or element inside should be position:absolute; You then just set the co-ordinates of this accordingly to position your element relative to it’s parent div.

Reset your CSS

Using a basic reset operation before you begin, can avoid you having to reset individual elements further down the line. Different browsers interpret default padding and margins, which could be avoided by simply adding the following code to the top of your stylesheet

* {padding:0; margin:0;}

Use shorthand CSS

Keeping your CSS conside, has benefits of keeping the file size down, but more importantly speed up your coding and boost your efficiency.
Combining items such as…

#box p {margin-top:5px; margin-right:10px; margin-bottom:5px margin-left:10px; }

into…

#box p {margin:5px 10px 5px 10px; }

or even…

#box p {margin:5px 10px; }

Michael Angrave

Nothing is known about Michael Angrave at this time.
This entry was posted in Tips For Web Designers and tagged , , . Bookmark the permalink.

2 Responses to 5 CSS Tips for Website Design

  1. Eswar says:
    October 14, 2010 at 11:40 am

    Good, shorthand css is nice tip to decrease css classes

  2. Smirs says:
    April 20, 2011 at 2:59 pm

    Thanks a Lot ! Useful Tips! I thank you a lot !

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>