Mar 29
Working with CSS, how to start…
2004 at 12.54 am posted by Veerle Pieters
Designing a web-page is one thing but converting into a web-page is something totally different. Today I want to share my experience on how I start this job. I can imagine that for an experienced web designer most steps will be obvious and crystal clear but for the less experienced ones there are a lot of question marks.
And of course I’m not talking tables this time, “tables are out” ;-) Yes, we’re talking CSS! For me CSS is the way to go from now on. You don’t only get nice clear and standard code, you also get a much lighter page and lets not forget the improvements if you need to update or apply changes. With tables it is a hell of a job, sometimes it means starting all over. With CSS it means more flexibility. But how do you start? Well here are some structured tips to start you off…
Analyze and define the areas / boxes / ID containers
First I analyze my design. How do I slice it up? With slicing I sure don’t mean table slices, I mean boxes or areas that will be converted into ID containers. Think in terms of a header, a navigation, a left or right bar and the middle area where you got your content. Draw them if needed on a paper and give them names.
After you define the big areas as described above. Next step is dividing each big area into smaller areas. These will be the nested boxes or containers.
Defining the background
Almost while you define your areas or boxes you have to think about how you will convert your background. First question you have to ask yourself is: “Which kind of background do you use? Is it a “flat” colored background, a pattern or does it contain an illustration or picture ?“ Depending on the kind of background you either decide to use a background color defined through the style-sheet or you save your pattern or background illustration or picture and refer to it through your style-sheet.
Just remember that each box or area can have its own background. In most cases you have several backgrounds. You have your “body” background and you have backgrounds where needed for some of your boxes.
Save for web
Now that you defined your areas you can start exporting and save your images to gif, jpeg or png. Nothing much tell about this phase, since it depends too much on the design itself.
Building your boxes with CSS
Now that we have saved all images we need to build up our web-page, we can define our boxes by CSS code. Give your boxes an obvious name, so you know what is what. Use comment code so you can find your way. This is very important since your list of CSS code can get very long. Start in a structured way. Start by defining the body tag, then the ID containers or boxes and then the text styles.
When you are in trouble try the trick with the border, or even better… a reader of my blog Jeff Minard suggested to use this : “outline: 1px solid #color; -moz-outline: 1px solid #color;“ (the last part is especially for Mozilla). This is better since a border adds 1 pixel of space around the box and if it has to fit right to the pixel then a border is not such a perfect idea. Thank you Jeff, this is very useful.
Not sure if I did forget something here but that is basically how I work all the time. If anybody can contribute to even better ideas or ways of working please don’t hesitate to share it ;-)
5served
1
Good call on the outline trick. I’ve always used a temporary border to help layout my pages but often find that adjusting the page when the border is removed can be quite a tedious chore in itself.
2
I just came across this extension for Firefox -you may know it already- which looks nice to those learning css and web design.
3
As far as structuring CSS code is concerned, I found this article very useful.
4
If you really are a beginner (as I am), you also need to know a few quircks about CSS…
1) Assign your DIVs a temporary height!
2) Learn about collapsing vertical margin behavior!
3) Floats and positioned elements can drive you nuts!
Thouroughly check out sites by Dave Shea (of course), Eric Meyer (also of course) and css.maxdesign.com.au
5
I always have trouble with Mozilla’s interpretation of the box model. If you have a DIV at, say, 50%, and add a border, you actually have a box that is 50% + 1px. When placed in another DIV, this could make the page scroll.
I always tack on -moz-box-sizing: border-box to my DIVs. This Mozilla selector makes the box as wide as YOU set it… border or no. It’s a bit easier than the outline trick, but… to each their own!
I love your new design, by the way. :-)