I develop websites since last two years now and I have hard time learning CSS (just spend a whole day creating a login box like twitter…). And sooner or later I fall back to table layout, and get things done (for almost everything I dig deep in to other’s source code and Google like hell… but I wish I know how to do it the way I normally figure out my programming problem instead of Google all day…).
And even after sometime if I achieve goal to create a perfect layout, and go back to IE for testing, everything is messed up.
I am the only guy developing it, so normally 70% of my time spend on design and 30% on programming.
I think I need to learn something more so that I spend less time adjusting my layouts and more time program it.
How you all programmer+designer work? And, how to master CSS?
When working with CSS, I find it is best to design and build the site first for a standards compliant browser (My preference is FireFox). Then, when you have it looking right in that, check it for Internet Explorer and other browsers.
For a design of any complexity, unfortunately, there will be time spent with multiple browsers open fixing a rule until it is consistant.
There are several improtant things to wrap your head around that will make your CSS life easier:
The first I would learn is the Box model. That’s the official W3C article on the subject, which is quite long, so I’ll include an image below as well, which simplifies it a bit:
It’s important to note that browsers calculate this differently.
Once you know what is causing things to size themselves, layouts should be easier to achieve in the same style as tables.
The second that helped me wrap my head around what was going on was specificity This article helped me a lot with working this out. The essential summary is that each type of selector (element, class, id) has a weight attributed to it and if an element has a css value with a higher weight, then it will nt be overwritten.
#id 0,1,0,0
.class 0,0,1,0
p 0,0,0,1
1,0,0,0
So, it doesn’t matter what your css files say, an inline style gets priority.
Example:
I’d still read the article. Twice.
The third thing to learn is how to support previous browsers (like IE6) and the bugs with which they will plague you. I am a fan of this site: http://www.positioniseverything.net/
They cover, with clarity and solutions, a great many of the browser bugs you will encounter when implementing cross-browser support with CSS.
Some of the bugs you will likely encounter with IE6 are: