Reserved Words

You should avoid using certain words when creating class or ID names. These words are frequently used in connection with other scripting languages so it is best not to use them.

abstract

boolean

break

byte

case

catch

char

class

comment

constr

continue

debugger

default

delete

do

double

else

enum

export

extends

false

final

finally

float

for

function

goto

if

implements

import

in

instanceof

int

interface

label

long

native

new

null

package

private

protected

public

return

short

statistic

super

switch

synchronized

this

throw

throws

transient

true

try

typeof

var

void

white

width


Writing Your CSS

A lot of how you write and organize your CSS file is just a matter of personal preference.

You can write your rules with properties and values on one line...

.myclass {font-weight: bold; text-align: left;}

...or you can place each property and its value on a separate line.

.myclass {
   font-weight: bold;
   text-align: left;}

It does save time, however, if you stay organized in the external CSS file. I will normally place all of my HTML selectors first, starting with the body rule. Next I will organize any IDs in the order they are being used on the page. After the IDs, I will list the classes again in the order they are being used. Last, I will place any miscellaneous classes, etc. they may not be used on every page.

To help you stay organized, you can add comments within your CSS file to help you recognize what a section is for. A CSS comment looks like this:

/* Anything written here will not be read */
/* This is where I can write notes about what follows */

Books

While you might rather curl up with the latest Dean Koontz thriller, having some good reference books available can be invaluable. The following books sit in my office and I still refer to them often. These books are available through Amazon.com, BarnesandNoble.com, SitePoint.com, or through your local area book dealer.

CSS Links

The Web Standards Project: Provides coverage of interim releases of major browsers' CSS implementations: http://www.webstandards.org/

CSS Validator: Validate your CSS file using one of three different methods. http://jigsaw.w3.org/css-validator/

Markup Validation Service: Validate your HTML or XHTML coding at http://validator.w3.org/

CSS School: The best teaching CSS sites available. http://www.w3schools.com/css/

CSS Reference Table: An excellent reference to CSS properties. http://reference.sitepoint.com/css/

CSS Inspiration

Zen Garden: An amazing CSS site. All of the examples use the same HTML coding, only changing the CSS file. http://csszengarden.com/

W3C Sites: A collection of really inspiration sites at http://www.w3csites.com/sites_thumbs.asp

CSS Play: A bonanza of CSS menus, photo galleries, and more. http://www.cssplay.co.uk/menu/index.html

CSS Layouts: A collection of CSS-based page layouts. http://www.dynamicdrive.com/style/layouts/