Both you and your client can probably agree on this basic premise. But, ideally, you want to give the client the total after the work is done. They want you to give them the total before you start. They always do. First, set your rates.
Some tasks are harder than others.
Don't be afraid to set higher rates for CGI than for HTML, for example. Also, remember that consulting is a function of your job and should be chargeable. Next, you need to anticipate how long you are going to spend on a project. In order to do that, you need to know what the client wants. They may not know what they want.