Is Absolute positioning a best practice or should I avoid it?

I am watching the ASP.NET learn video on http://www.asp.net/learn/3.5-videos/video-13.aspx
and it is showing you can place controls on a page using Absolute positioning. I am just wondering if this is a best practice or should I avoid Absolute positioning? It seems like a nice, easy feature, but there must be some reason why it is not selected by default in the VS IDE.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Many users change the font size of your page by configuring their browser settings. If you use absolute positioning, things will not align right for them.

In absolute positioning, when your page gets more complex, a single design decision would require you to reposition all of the elements, but in relative positioning, you would only need to change one value, and all the other elements would adjust accordingly.

Method 2

Absolute positioning takes the element out of the flow of the document. This means that it will no longer align with other elements. There are very good reasons to do this sometimes but generally you want to avoid it.

ASP.NET is notorious for using bad HTML/CSS practices. This framework is designed for ‘rapid development’ not ‘elegant, web standards development.

Method 3

You are right to be suspicious 🙂

Basically, don’t use it for controls.

I only use it for dialogs, or other features which I can calculate the correct position relative to the page size.

Method 4

I think this question is more about css than the visual studio. Because of the reasons explained in other answers, you should use relative positioning where possible.

This doesn’t mean absolute positioning has no use at all. Check out http://csszengarden.com/, to see how you can use a simple html structure and still use some really interesting designs.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x