views:

179

answers:

2

Some websites use a DIV with relative position and then they apply absolute position to the child element in order to place the element in the desired position (e.g. left 0 or right 0). Others use floats, for instance float: left or float right. Which one is better? or in what kind situations they are better?

Since I use fixed layouts, I'm better off using relative positioning and relative positioning?

A: 

Using a DIV with relative position and then they apply absolute position to the child element is sort of a trick where is floating is not. Decision is yours which one to go with. But with more experience you will come to know which option to go width.

As far as i am concerned, i usually use the first option for something like creating image maps using css for fb apps or other places where image maps are not supported. There are other occasions as well where i use the first option. The later option is generic and fits in most situations.

Sarfraz
+3  A: 

I my experience using absolute positioning works well on elements you are in 100% control of in terms of size; like a logo, a meny, rss links and things like this. Then you can place these elements exactly where you want them.

I prefer using float when I am displaying dynamic content on a page, since the size of the element can change, and the placement of all elements in relation works really good with floats. Just remember to clear the floats when needed!

code-zoop