Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the problem with Visual Studio.Net's "absolute positioning", and how is that problem fixed by CSS's "absolute positioning"?

For years, Visual Studio.NET has offered "absolute positioning" for ASP.NET, whereby you can drag controls onto the designer canvas wherever you want them to be. However, there has always been strong advice not to use that feature. Instead, the common wisdom said you should use "Flow layout", because if you were to use VS.NET's "absolute positioning", your screen would not render correctly for users whose screen resolution was different from yours.

However, that's old advice. A while back, CSS came out with the ability to perform "absolute positioning" in a standards-compliant way, and most or all browsers caught up with CSS and have implemented CSS positioning correctly (or well enough at least).

So the current recommended practice is to position elements using CSS absolute positioning.

Question is: What is it that CSS does correctly about absolute positioning, that Visual Studio does wrongly? How can CSS absolute positioning be OK even for users who have different screen resolutions, while Visual Studio.NET cannot?

UPDATE: The responses here have cleared the matter up for me. Here's how I summarize it:

  1. Ages ago, VS.NET defaulted to using absolute positioning for everything. This is how VB worked from its beginning (meaning, Windows apps before the web even existed), and VS.NET was made to feel similar to VB.
  2. However, using absolute positioning for everything on a web page is a very bad idea. See one of the responses below for some concrete examples of why.
  3. Since using absolute positioning for every single control on a web app page is such a bad idea, all that advice about using "Flow layout" sprung up. It was a way of working with VS.NET without absolutely positioning everything.
  4. Now that CSS is so mature and widely supported, and is the preferred mechanism for positioning and appearance, it is STILL CRAZY to absolutely position everything, and for the same reasons. Most items should be allowed to position themselves "in the flow". However, for some elements here and there, absolute CSS positioning might make sense.
  5. The mechanism VS.NET has always used to perform absolute positioning is actually inline CSS styles.

Great to have all this cleared up. Thanks.

like image 599
Charlie Flowers Avatar asked Dec 31 '25 20:12

Charlie Flowers


1 Answers

As a general web development point absolute positioning is frowned upon. It has some rare uses but not many in a good css design.

Visual studio acheived this layout by using inline css styling, but it was still css absolute positioning.

The best way to develop a web layout is to start with the content rendered into valid HTML elements. Then look to improve the layout using CSS by applying proper cascading rules to those elements. Then add classes to individual elements which need to layout differently from the standard elements.

Lastly to add any whizz bang features you can use Javascript like Jquery to visually enhance the look and feel of standard html controls.

This way your site can "degrade gracefully" with browsers which are less capable.

like image 65
Richard Avatar answered Jan 02 '26 08:01

Richard