homepage Welcome to WebmasterWorld Guest from 23.22.179.210
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / CSS
Forum Library, Charter, Moderator: open

CSS Forum

    
Is specifying an abolute position better than using margins?
Any advatnages / disadvantages of either technique?
vmaster




msg:1222481
 9:13 am on Feb 12, 2003 (gmt 0)

Is specifying an abolute position better than using margins for positioning elements?

 

mastermind085




msg:1222482
 9:39 am on Feb 12, 2003 (gmt 0)

i guess by specifyin absolute position, ur formatting might become browser dependent...
am i right?

vmaster




msg:1222483
 10:48 am on Feb 12, 2003 (gmt 0)

I don't think so, but I'm a newbie to the whole world of css myself. Any experts around please ...

BlobFisk




msg:1222484
 10:54 am on Feb 12, 2003 (gmt 0)

Hi vmaster,

I would tend to use absolute positions more often than margins, but it does depend on what exactly is trying to be achieved. For a liquid layout, margins are quite important, but for positioning an element on a page, an absolute position is more accurate.

Longhaired Genius




msg:1222485
 10:58 am on Feb 12, 2003 (gmt 0)

In my opinion it's best to use margins and padding to position elements on the page. This makes it easier to create a liquid layout that will flow to fit various browser window sizes.

It's good practice to try out methods for yourself on dummy pages until you find something that works for you, before you dive into your project for real.

tedster




msg:1222486
 12:27 pm on Feb 12, 2003 (gmt 0)

I agree that this is dependent on what you are trying to achieve.

I inherited one site that had over 50 separate elements on a page, all positioned absolutely relative to the BODY element. What a labor that page builder must have gone through finding all those x,y cordinates! But the page was almost all images and it made a kind of sense to put the slices together that way.

A more liquid layout -- one that uses padding, margins, etc -- has proved the most practical for me so far. Absolute positioning on a grand scale tends to buld up the size of the code. You need either a separate ID for each element or you need inline style attributes for each element, and it can create a maintenance hell.

Plus, if there is text involved, a user stylesheet override could cause a major mess.

Nick_W




msg:1222487
 12:51 pm on Feb 12, 2003 (gmt 0)

Agree with the others on the 'depends what you're doing' front.

Personally I lean toward a mixture of the two. I like to absolutely position elements like left/right navigation and then give the content area margin/padding to compensate for the space taken by the nav element.

This creates a semi-fluid design with one or two elements fixed and the rest liquid.

Nick

Birdman




msg:1222488
 12:54 pm on Feb 12, 2003 (gmt 0)

You can use absolute positioning for fluid type layouts, though.

div.left{
position: absolute;
top: 0px;
left: 0px;
width: 20%;
}
div.right{
position: absolute;
top: 0px;
left: 20%
width: 60%;
}
div.mid{
position: absolute;
top: 0px;
left: 80%
width: 20%;
}

vmaster




msg:1222489
 1:39 pm on Feb 12, 2003 (gmt 0)

That's quit clever Birdman. Any specific reason why we've never seen such usage commonly, as it seems to suit my application well.

Birdman




msg:1222490
 2:12 pm on Feb 12, 2003 (gmt 0)

I don't really know how many people go that route, but it has worked fairly well for me in a few instances. I believe I used it because it solved margin and padding discrepencies between IE5 and Opera, which is unfortunelately all I test in right now.

Birdman




msg:1222491
 2:17 pm on Feb 12, 2003 (gmt 0)

Also, using absolute or mixed(per Nick's post) gives you the ability to present your main content at the top of your HTML doc. Spider food ;)

vmaster




msg:1222492
 2:30 pm on Feb 12, 2003 (gmt 0)

Birdman, can I suggest an online tool to test how your site would appear in different browsers, or would that be against the terms of the forum. I find it quite useful.

kevinpate




msg:1222493
 2:42 pm on Feb 12, 2003 (gmt 0)

There's always that lil' sticky mail route if posting the url in that circumstance is a no-no

vmaster




msg:1222494
 2:49 pm on Feb 12, 2003 (gmt 0)

Thanks for the suggestion. Never had the need to use sticky mail before. Anyway, since this might be useful for others too, it simply allows you to view your site in ANY BROWSER, and that literally gives away the site address.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / CSS
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved