The Most Active and Friendliest
Affiliate Marketing Community Online!

“AdsEmpire”/  Direct Affiliate

Floats Or Absolutes?

espmartin

New Member
affiliate
For you CSS designers out there, I'd like to ask if you had a web design that
you would prefer to be laid out a certain way - do you prefer floats or positioning?

Both have their benefits and drawbacks, but both can do the job for specific
layouts. I actually love using both. I'll do floats on one site, then do AP
(Absolute Positioning) on another. They are - unless you have a specific layout
that only can be achieved by AP - interchangeable at times.
 
Most of the time you need combination of both to achieve the best (or desired) result
 
I used to use absolute all the time but thats only cos I didn't know about floats - now I always float - its amazing what you can do with margin!
 
There are good reason to use both in the right places.

Float Example
float:left is extremely useful for step and repeat in CMS when horizontal rows have more than one output. By this I mean say a div 250x250 containing a product pulled from the Database by a qualifued query which needs to appear in 3 rows of 3.That is something that is verrrrry difficult to achieve reliably any other way.

Absolute Example
Absolute is the only way to pin a Graphic Banner to the top of your page while putting it last in the HTML running order to allow the H1 tag to be first in the body.

The question Absolute or float is simmilar to the age old question "Tables or CSS" there is no absolute answer, excuse the pun. Both have their uses and trying to work a table free design when part of the page is crying out for a table is often a source of quirky CSS sometimes requiring Browser Hacks.

Most times, there is more than one way to achieve positional control but frequently one method is actually far more appropriate for various reasons. However many designers choose the method they feel most comfortable with and that does not always produce the best results.
 
Most of the time floats. I rarely use absolute for main elements of a page. most of the time I use absolutes are in special type of navigations where I control the position of the <a> tag within a CSS image replacement.
 
I used absolutes alot, in the beginning. But once I got a widescreen monitor, it really put the float into perspective. Now its all i do for the most part. Still working on bettering the floats within a container div, that gets kind of tricky at times
 
I find absolute positioning is easier to work with, usually with a positioned parant element centered with margin: 0 auto; and with a min/max-width applied, this gives me some control of the layout, while still supporting some larger screen resolutions.

I only use floats for hoizontal menus or image galleries and similar, so somtimes i might end up with a mix between the two.


Now for a specific layout where i always use AP is when creating a truly fluid box with round cornors, i even went as far as to make an example some time ago, which can be found at my website somewhere in the CSS Tutorial.

I don't think thats possible with floats alone, you can however fake it using some impractical techniques or javascript, but using JS for layout is a bad idea.
 
The thing is, they both have their use, and they are both equally good. Some layouts cant be made with floats, and some cant be made with AP.

The coding required is about the same, i looked into this by creating a 3 column layout with AP, and creating the same using floats. I even used multiple classes to lower the code. Markup and CSS was about the same in size, only few bytes difference.

I usually use AP, mainly to enable the use of my css based border technique. Find it equally good for multi column layouts, only few cases being the exception. Mainly around headers and footers, thats where i find float easier to deal with.
 
Last edited:
It depends. Absolutes may get troubles on different browsers, but sometimes it's an easier solution than floats.
 
banners
Back