I am currently working on my first website. I have no idea where to start on the CSS page, or if there are any standards that I should be following.
I would appreciate any links or first-hand advise.
An error that beginners make quite often:
CSS is semantic as well. Try to express concepts, not formats. Contrived example:
div.red
{
color: red;
}
as opposed to:
div.error
{
color: red;
}
CSS should be the formatting companion for the concepts you use on your web site, so they should be reflected in it. You will be much more flexible this way.
Aside from the great resources pointed in the other answers, here are some tips to structure the way you work on the CSS:
Do the work in the following order...
Put a link on your page to the W3C CSS validator (if your site is visible from the internet) and keep hitting it every so often.
Keep all your styles outside of the HTML.
It's good to have IE6/7/8, FF2/3 and Chrome/Safari. Opera would be nice too. Keep changing the browser you open your page in while working (unless you're digging into a particular browser issue :-)).
Add comments what each rule does and why. Keep the dev version of the CSS checked in and once you're done, then remove comments and whitespaces and compress multiple rules into one for production.
Update: As Bobby Jack mentioned, I missed to mention the debugging tools. You can use IE Developer Toolbar (for IE) or Firebug (for FF) or the integrated Inspection tools in Chrome to inspect which rules are applied to particular element, or modify the style of an element on the fly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With