Archive for March, 2009

CSS: Problems with Float

The float property in CSS is a blessing if you ask me. I use it almost exclusively for layout, with occasional tables or absolute/relative positioning. The float property leaves your layout incredibly fluid so that you can change it very easily. However, there are some difficulties that are easy to run into when using the float property.

What float essentially does is force block level elements to not actually take up space in the document. Only floating elements will move around other floating elements, but you might find that sometimes your elements overlap or float around another when you just don’t want it. This happens very commonly when you define the height of an object such as a div, and float elements inside of it which actually will exceed the height of that div. Some browsers will not expand the containing div automatically. Other times, you might have a div floating left, and another immediately after that, but you don’t want them next to each other horizontally. For all of these problems, there is one simple and easy solution:

The “clear: both” property: Think of the clear property as a horizontal line that forces everything written after it in markup to appear below it (within the containing div). The most common implementation I’ve ever seen is a div solely created to contain this property. I’ve seen this all over the web, and I use it all the time, without any hesitation. Make a CSS declaration like this:

   clear: both;

And the HTML:

<div class="clear"></div>

Putting this div below another other set of divs will essentially create a forced break between everything written above it in the HTML, and everything written below it. This is limited to the containing div though. I personally can only think of a single situation when you wouldn’t want it limited to the containing div (if you wanted to force a two column layout to be the same height, but you just can’t do that). So yeah, stick to this… you won’t regret it!

Finding Web Design Clients

Finding clients, especially when you are new to the web design business, can be both incredibly easy and difficult. It is easy because there are actually a lot of people out there in need of web design services. Small businesses are leaving the yellow pages en masse for the web, and most of them aren’t very web savvy. However, because most of them aren’t web savvy, they can be incredibly difficult to work with. So really, the better question is, how do you find good web design clients.

First let’s figure out some places you can look for any web design clients at all, and then we’ll tackle weeding out the bad ones.

  • Craigslist: That’s right, depending on the city you are in, you’ll probably see several posts a day related to web design and graphic design. The other good thing is that you don’t even have to limit yourself by city if you are alright working remotely. The only warning I give for that is that not being able to meet clients in person can cause some issues.
  • Guru is an online marketplace for freelancers and employers. I personally have never used it, and it does have a few fees mixed in there, but if you are looking to do contract work for the majority if your income, you’ll need all the help you can get, and this one is definitely worth it. There are other sites out there like this one too, just look around a bit.
  • An Online Portfolio: Make sure you have examples of your own work available to people. Then advertise this by passing out business cards, purchasing online advertising spots, or linking to it from sites you’ve already worked on. Just having something ready to go shows potential clients that you are viable, and will encourage them to reach out to you instead of you reaching out to them.
  • Business Cards: Making as many connections as you can is always a great idea. The more clients you meet, the more people in the web business you deal with, the better. So go mingle, and pass out a nice business card to everyone you can. They might pass it on to someone they know. A majority of my clients have come through word of mouth and other connections I have, as compared to searching myself on websites like Craigslist and Guru.

But that is really only half the problem. You’ve really got to be able to weed out the bad clients, the ones that will be a pain to work with. Trust me on this one, for every good client you find, you’ll run into two or three bad ones. So now just a few suggestions to clean out the grime.

  • If your client tries to swindle you down to a pay rate way below your average, or is incredibly surprised at “how high” you charge for your services, then keep in mind they don’t seem to value your work enough. Web designers can charge anywhere between $30 and $100 an hour in my experience. If they think that $30 is absurdly high, make it clear to them that is isn’t, and if they don’t understand, then drop them!
  • Make sure they have an idea of what they actually want. When clients don’t know what they want, then it’ll be very difficult to produce anything they like (at which point they blame you). Then let’s pretend you magically figure out what they want, they are just as liable to change it up on you and request alterations all the time. Either don’t sign with this client, or if you do, make sure you are charging an hourly rate instead of a flat rate, so you get paid for your iterations.
  • Often times, small business owners are looking to get on the web, but they have little expertise with computers or the web at all. This will make communication difficult, and you’ll often find them nitpicking over minute details that in reality are not important. You probably won’t get screwed over here, it’ll just be a huge hassle.
  • If a potential client doesn’t email you back for 5 days, then that means they are probably disorganized or bad at communicating. Either way, this could be quite dangerous. Set up a strict communication schedule, or ensure that if anything falls to the wayside, that they’ll recognize when it is their fault.

Those are just a few suggestions for weeding out the bad clients, so you can keep the good ones around. Got any other questions? Let me know, and maybe I’ll have a few suggestions for ya!

CSS Positioning and Layout

CSS has two primary benefits. One is the ability to easily edit the look and feel (the theme if you will) of your website by changing very little code. This is evidenced by a quick visit to the CSS Zen Garden which has the same HTML code, but uses different style sheets to make it all look completely different. The second is positioning and layout which allows to easy move different pieces on a page because it doesn’t ascribe to the rigidity of tables.

However, CSS layout can get a little confusing when you are just starting out. So this article will discuss the different attributes you can assign to tag objects and when each of them is appropriate.

The position property has 4 possible values of static, absolute, relative, and fixed. Static is essentially the default that lets an element just fall wherever it falls. You’ll only find yourself defining an element as have a static position if you need to correct for a previous assignment of something else other than static. The fixed value will put an element at an exact location within the browser regardless of scrolling or screen size. The fixed value is always used in conjunction with the top, right, bottom, and left properties which will be discussed after positioning.

The remaining two properties are the more common definitions, and are also always used in conjunction with the top, right, bottom, and left properties. Absolute positioning is used when you want an element to exist at an “absolute” location within the page. The only difference between absolute and fixed is that fixed ignores scrolling, whereas absolute does not. So if I wanted the logo of the website I’m designing to always be located exactly 10 pixels from the top of the window, and 30 pixels from the left (and if I scrolled down the page it would go out of view), then I’d use the following CSS:

   position: absolute;
   top: 10px;
   left: 30px;

I personally think that absolute positioning is a bad idea because it leaves you with something almost as rigid as a table. To move something around you have to constantly adjust pixel positions, and use z-index in case objects overlap. This can sometimes be useful so you don’t have to layer things using background images with multiple divs, but in general, I personally choose to avoid it. Then there is the relative value. Relative positioning is exactly what it sounds like, it positions an element relative to where it should be located. So if an element naturally falls at a certain location, and you give it a “top: 10px;” and “right: 30px;” then it will appear 10 pixels further down, and 30 pixels left of that certain location. This is also occassionally useful, but I personally prefer another option… floating. This I’ll discuss soon.

Top, Right, Bottom, Left:
These four properties are used when a position of fixed, absolute, or relative has been assigned to the same element (such as a div or an img). These positions can be set using pixels or any other length measurement that CSS accepts, as well as %. They can also have negative values which is helpful to push things around when you need to. Again, I however personally prefer floating my elements.

If you ask me, the float property is the absolute best characteristic of CSS, and it blows position out of the water. Why do I love it so much? Well, I’ll admit that it can be finicky, but once you get used to how it works, it is absolutely fantastic for building very fluid designs that you can easily change. Float only has three options, left, right, or none. None is the default value. If you add a “float: left;” to your definition then that element will move as far to the left as it can, meaning within its own parent element. Giving is a “float: right;” will do the same thing but obviously to the right instead. Check out the example below of two divs, one floating left, and one floating right:


<div style="float: left; width: 150px; border: solid 3px #444444; padding: 5px;">
  This div will float left
<div style="float: right; width: 150px; border: solid 3px #444444; padding: 5px;">
  This div will float right

And the outcome:

This div will float left
This div will float right

So now that you see how the float works, you might be able to see why it can be so helpful. Imagine just having to change two words in your CSS file, and those two divs would switch locations. Now the reason it can get finicky is because of space issues. An element will float within its parent element as high up as it possibly can. So that means if I increased the width of those sample divs to more than half the allotted space, then the second div would be forced below the first (but still on the right side). You can apply float to a whole lot of elements, but primarily you’ll probably be using it with div, img, and p.

More notably, float is used to make text wrap around other elements such as an image. This is incredibly common and incredibly useful. Just apply a float to the image right before the paragraph and the paragraph text will wrap around it. You’ll probably also want to apply a margin so that the text doesn’t touch the image though.

Well, good luck with your positioning escapades. Let me know if you have any problems.