.NET Daily

ASP.net

Web Development Coding Standards Series – CSS

Posted on .

Web Development Coding Standards Series – CSS

Introduction

This post is part of a series that covers most of notable web development coding standards that you should follow.

You can download the document with all of the post from here: [download id=”8″ format=”1″]

You can see here the other posts within the series.


1. CSS General Rules

1.1 Use margin: 0px auto; as a CSS attribute for centering a div inside container;
1.2 Use .px as measurement unit in design. It’s easier to control than .em and all the developers on a project can understand it;
1.3 Use CSS reset class, example: *{margin: 0px; padding: 0px}. You can add additional attributes to this class depending on your requirements.
1.4 Use structural naming convention instead of a presentational naming convention:
Ex:
Good:

Bad:

2. CSS Formatting

2.1 Use Single-Line formatting. This is the most space and size efficient way to write CSS:
Ex:

2.2 Use one blank line to separate logical groups of styling:
Ex:

2.3 Order your CSS properties. For example, if you are styling a “h1” tag, put first the font-related declarations then color-related declarations and finally the position-related declarations:
Ex:

Comments are optional, so is the formatting.

2.4 Order the CSS items in groups. This way you can easily read the contents and jump straight to a particular section. Prepending each heading with a dollar sign makes it unique, so that a search will yield only headings:
Ex:

Darius

Darius

Darius Dumitrescu is a creative Senior CMS Consultant with in depth .NET knowledge, focused on Web Development and Architecture Design.

There are no comments.

View Comments (0) ...
Navigation