views:

1078

answers:

19
+14  A: 

Check out Designing With Web Standards by Jeffrey Zeldman.

Daniel Pryden
I have an interesting story behind this. After observing this answer go up I contacted Zeldman thru his website, requesting him to respond this question. He mailed back saying that this was exactly the problem he faced when he started. He replied “I wish I could answer your questions with a comment or two on your web page, but I can't.I do answer them (and more) in DESIGNING WITH WEB STANDARDS, especially in this new third edition that comes out in two days.Send your address to the gentleman I've cc'd on this email, and we will make sure you get a free copy.” The book is awesome, must have!!!
Quintin Par
+5  A: 

I'm assuming you've installed Firebug?

Also, http://www.doctype.com might get more relevant results.

Dean J
+1 on firebug. it saves so much time on specificity issues.
centr0
Hmm no, doctype is highly unusable and the answers are usually not too helpful. I hope SO builds an HTML/CSS exchange, comments, badges, the whole system is great and almost flawless.
Nimbuz
+2  A: 

Practice, practice, practice. You know what you don't know, and that is the key to success in my mind. Every project you do, try to improve your skills, and eventually it will become second nature to do it the right way.

Eric Meyer's Cascading Style Sheets 2.0 Programmer's Reference is a great resource to understand exactly how selectors and rules work, and serves as a great reference as well.

Some thoughts on what you posted.

  • A Master Reset style sheet will help with browser differences.

  • And Tabular data should use tables.
    It's layouts that should avoid table tags in favor of css.

Matthew Vines
E.Meyer is the master :)
ChrisR
A: 

You could start by reading some good books on the matter. The ones of Eric Meyer are hands on and of very high quality. The other book that of which I learned a lot was the Zen of CSS design book.

And the rest is effort and practice. Be sure that you understand why something works the way it does, don't be satisfied with 'trial-and-error' css development.

PeterEysermans
A: 

Well, I will address some of these issues as best I can.

The difference between display:none and visibility:hidden is when the display is set the space for that item is not reserved. So imagine it as when the display is set the item is 'gone' off the page. Whereas if you are using the visibility option, the elements are on the page, in their place just invisible. Did I explain that clearly? Hopefully, that makes sense for you.

As far as the padding, border and margins, this is all referred to as the CSS Box Model. The information is contained as the element, its padding, border, then its margins. So padding is the distance between the element's content and its border whereas the margin is the distance between the border and the neighboring element. Again, I hope this helps clear this up for you a little bit.

Transitioning to CSS is sometimes tricky but well worth it.

Slevin
A: 

Well the basics are quite simple, you should really get a hang of the quite easy if you've already don't some css coding.

The best practices, browser quirks, hacks and other sketchy stuff concerning crossbrowser layout is something else.

Here is my suggested reading list, all of them are on my bookshelf and certainly worth reading! If you ask me i'd say these are the book you should have read if you are a webdesigner.

ChrisR
"Well the basics are quite simple, you should really get a hang of the quite easy if you've already [done] some css coding." **Except that he has done some, and he doesn't get it yet, which is why he's asking this question.**
Nathan Long
A: 

for me, Pro CSS and HTML Design Patterns by Michael Bowers changed it all. no more endless trial-and-error, but problem - pattern - solution. indispensable.

ax
+9  A: 

Here are some general rules to live by:

  • Tables are good for tabular data. If the data you're presenting belongs in a table, don't go out of your way trying to make a grid out of <div>s. Doesn't make sense.
  • As far as layout is concerned, use <div> tags, stay away from tables. Get to know the float property well. With CSS3, there are going to be new, improve standards to the display property. Learn them.
  • display: none completely removes the element from the viewport. Conversely, visibility: hidden retains the whitespace that the element would have otherwise taken up. In both cases, the element remains in the dom.
  • General rule of classes and IDs. Page elements and IDs should have a one-to-one relationship per page. For example, #Column1, #Column2, #Footer, #Header. Page elements and classes, on the other hand, should be a many-to-one relationship, like: .container or .navLink. Use classes when you know you're going to be using a particular element quite a bit.
  • Think in terms of efficiency. The less style rules you have, the more quickly your page will load and the easier style issues will be to debug.

I have about a million other things to say but that should get you started.

Plan B
+8  A: 

For layout-driven CSS, be sure to check out Everything You Know About CSS Is Wrong. It's a bit cutting edge, since IE 7 doesn't support display: table (pity, I know), but it does cover traditional layout CSS techniques like floating and absolute positioning, and provides a good transition from table-based layouts to CSS ones. I highly recommend it.

I don't know if you're building off of any dynamic language or if you're just coding raw HTML, but you should also look at using SASS in your projects, as I think it helps force you to pay more attention to inheritance. Otherwise, reviewing more "rudimentary" tutorials (like CSS for Dummies) might actually be helpful, as they go over a lot of CSS's fundamental principals in detail.

Lastly, CSS works best when you have semantically correct (x)html underneath the hood. In my opinion, it's easiest to see and learn "good" CSS when you have great, semantically correct html underneath. Here's a good overview of when to use what tags. Generally, I find it best to write my content with no regard what-so-ever to how it will look later, then use CSS later to make it gorgeous.

As always, you can pick up lots of neat tips and tricks at CSS Tricks, which have always helped me learn more about the correct usage of the language (like when I learned about overflow: auto for contained floating elements! Genius!).

Hope that helps!

neezer
+1  A: 

Read CSS: The Definitive Guide by Eric Meyer. He explains why CSS was created, how it works (according to the standards), and will give you the background to understand the finer points. It also makes a good reference.

Nathan Long
+1  A: 

Experiment in Firebug

I don’t know what this picture in firebug is conveying

Firebug itself can help you there. Do this:

  • Create a div with some text in it.
  • Use CSS to give it padding: 5px; margin: 5px; border: 1px solid black;
  • Examine it in Firebug, as you show in your question.
  • Click on any one of those numbers in the box model it's showing you, and start pressing the up and down arrows (or type a different number).
  • See how it changes in real time? This is one of the best things about Firebug: it lets you tweak without reloading, then modify your stylesheet when it looks right.
  • Keep doing this until you understand how padding, margins, and border work.
Nathan Long
+7  A: 
  1. Visit CSS Zen Garden to see what you can do only with CSS.

  2. Visit W3 schools and follow the tutorial. It might seem simple for you, but you will learn the basic stuff.

  3. Visit some sites, such as A list Apart to see how to do things and learn tricks.

  4. See if a CSS framework suits your needs (such as 960 Grid).

Anax
+1 for CSS Zen Garden and A List Apart -- both are excellent resources.
Daniel Pryden
http://developer.yahoo.com/yui/grids/ are also good one.
cetnar
A: 
Whenever a page loads slowly the html elements are out of place and fall into order only when it’s completely loaded.
  • Are you putting your stylesheets at the top, in the <head> section?
  • Are you declaring explicit sizes for images, or does the browser have to guess, then rearrange things when the image shows up?
Nathan Long
+2  A: 

Plenty of people here give good advices. I'll just add two more:

  • First, try to write valid (X)HTML. You can easily test your HTML code using W3C's HTML validator. Focus mainly on content, not on style.
  • Second, try to write valid CSS, preferably in a separate .css file. Avoid using the style attribute. (This part can be hard, if you want to support certain old browsers from Redmond). You can test your CCS using W3C's CSS validator.
Stephan202
+1 for the validators
Graeme Perrow
+1  A: 

I think you should use, for your layout needs, one of the so called "css frameworks" (960.gs for example).

They are fast and reliable enough to build cross-browser layouts and also easy to read and understand as well, so you can learn all the good practices while you are coding.

CSS are easy and aren't a real programming language: don't be afraid of the word "framework" ;)

Gianluca
A: 

Depending on your learning style, I might recommend going straight to the source: the definition of CSS. You can find each of the various specs here: http://www.w3.org/Style/CSS/. While the specification doesn't really cover specific browser quirks (if it did, they wouldn't be quirks, would they?), it does a really good job (for me) of explaining how each piece works.

Michael Gorman
A: 

http://htmldog.com/ is IMO one of the definate resources to learning frontend web-development the proper way.

Arve Systad
A: 

I will tell you my secret: follow this two classic tutorials

Listutorial

Floatutorial

And you'll know 80% of what you need to know about CSS.

Soska