Faux Absolute Positioning
Issue № 261

Faux Absolute Positioning

There are two popular approaches to positioning with CSS: float and absolute positioning. Both approaches have their pros and cons. My teammates and I have developed a new positioning approach that gives us the best of both worlds. After quite a bit of experimenting and testing, it’s time to share the technique with the rest of the world and see how we can work together to improve it. I’m calling it “faux absolute positioning” after the faux columns technique that simulates the presence of a column.

Article Continues Below

Why do we need another CSS layout technique?#section2

Many website designs are based on a columnar layout with a header and footer.  With absolutely positioned layouts, it is almost impossible to position the footer if the columns can grow vertically. With floated layouts, unexpected content changes can cause entire columns to wrap (“float drop”), as described by Shaun Inman in Clearance. This is undesirable and hard to control in Internet Explorer because of IE’s problematic treatment of width.

Our use case was even more complex: my team was developing a web-based WYSIWYG form generator that allows the user to drag items to arbitrary locations on a canvas.  We needed to let our users create beautiful forms that didn’t use overly static layouts and to let them align columns as needed.

For example, let’s assume we want a form that puts the postal code and city fields on the same line because they are semantically connected. To accomplish this, we tried using floated positioning inspired by the Holy Grail technique. Using this method, we needed to adjust the width, borders, margins, and/or padding of the postal code field to pin the city field to a fixed horizontal position. That was a problem because if the width of the postal code field needed adjusting, or if we wanted to adjust the amount of whitespace between fields, the city field would need to move as well. The more elements on a page—the more cells in your grid—the more tedious this kind of adjustment becomes. Additionally, the positioning is sensitive to the slightest change in a number of parameters, which makes it nigh impossible to control in case of dynamic form items.

Next, we tried using absolute positioning. This gave us much more control over the positioning of the items and is robust. But absolutely positioned elements have no height, and that caused the containing element (the canvas) to collapse. This made it hard to position content without making everything absolutely positioned—which is impossible to achieve with dynamic content.

A different approach#section3

Finally, we tried a solution based on finding a way to calculate the left offset from a fixed position, as opposed to calculating it from the right edge of the preceding element. We managed to do this using a combination of position: relative, left: 100% and a negative margin-left.

Our method starts by building a grid of lines and items. We can place any number of items on a line and any number of lines in the containing element:

<div id="canvas">
  <div class="line">
    <div class="item" id="item1">
      <div class="sap-content">content here</div>

…and so on. Every item has an extra sap-content div with several purposes:

  • it prevents the redraw bug in IE6,
  • it gives us extra flexibility to add padding (example below), and
  • it lets us play with position: overflow (without breaking the grid!).

The generic CSS applied to these elements is as follows:

.line {
  float: left;
  width: 100%;
  display: block;
  position: relative;
}.item {
  position: relative;
  float: left;
  left: 100%;

To position a particular item, all we need to do is give it a negative margin-left and a width. For example:

#item1 {
  margin-left: -100%;
  width: 30%;

With some extra styling, for demonstration purposes, it looks like this:

Example of Faux Absolute Positioning in action.

The generic CSS positions every item at the right side of the canvas, with each item’s width based on its content and all items floated in their HTML source order. The margin-left is now offset from the right side of the canvas instead of from the element to its left.


With faux absolute positioning, we can align every item to a predefined position on the grid (as with absolute positioning) but items still affect the normal flow and—thanks to clear—have many of the same advantages as normal-flow elements. Every row in the grid will always have height dependent on the content or as defined in CSS, and will always take up 100% of the width, no matter how many columns are defined in the row. Furthermore, we can avoid using cumbersome margins or padding to adjust the amount of whitespace between elements—which is a plus, since those techniques almost always require us to use IE6-specific hacks to compensate for the browser’s box model.

Another advantage of the technique is that it mitigates much of the fragility of floats. When the content of a floated box is wider than the box itself, it pushes the next box to the right (and by consequence, the box often drops down). With faux absolute positioning, the box to the right stays in place, no matter what. The content of the boxes may overlap (depending on other variables such as overflow: hidden) but that’s all—and in our view, it’s better to risk overlap than risk breaking the whole layout.

Honestly, I was a bit surprised that the technique worked so well. It uses valid HTML 4.01 and CSS 2.1, and negative left margins are widely implemented in browsers. And there’s more good news: it works with fixed and liquid designs, it can be combined with equal height columns (though the issues with this solution remain), and there is the possibility of combining fixed-width and flexible-width columns (see the example below). It is even possible to use faux absolute positioning recursively, e.g., use a positioned item as the container for new lines and items.


Faux absolute positioning is very much inspired by and intended for grid-based design and is more rewarding with more complex layouts. If you have a two-column fixed-width design, this may not be your technique of choice.

Additionally, faux absolute positioning will not work for every situation. If you want to align elements on the left, you cannot use a unit that is different from the unit in which the width of the canvas is defined, because you cannot calculate the offset. For example, if you have a canvas width: 800px and want a left offset of 2em for your item you cannot calculate the margin-left because you never know how many ems fit in 800 pixels.

And since it is a new technique that hasn’t been tested by thousands of users, it should still be considered experimental, as you may see unexpected results in your actual combination of markup, CSS, and browser.

One remaining issue: when an element larger than the canvas precedes other elements in the HTML source, the trailing elements on the same line will be pushed to the right by an amount equal to the difference in width between the the first element and the canvas.


The first example is a three-column liquid layout with fixed side columns, like the Holy Grail. I have implemented this layout as a template for Drupal, a popular open source CMS. There are a few things to note:

  1. The left and right columns have widths in pixels. Therefore, we cannot calculate margin-left for the main content, because we don’t know the width of the canvas or the width of the left column as a percentage of the canvas. The solution is similar to the Holy Grail: position the main content with margin-left: -100% and width: 100% and add padding to provide the necessary space for the columns.
  2. Left, main, and right columns are rendered at the same hierarchical level, so we may need something like z-index: 100 on the columns.
  3. Padding for the left and right columns is added to the extra div.sap-content; this keeps our math simple while affording us a great deal of flexibility.

The second example is a five-column liquid design in which canvas, lines, and items are all sized in percentages. The addition of images, borders and paddings have no effect on the overall positioning, even for images that are larger than the containing element, as is demonstrated with the old map of Maastricht in the example.

No hacks required!#section7

Our approach requires no hacks and it works with all modern browsers (Safari, Opera, Firefox, IE7) as well as IE6 and even IE5.5/Win. It does not work in IE5/Mac, but since this product has been discontinued, it is not on our priority list.

The approach is also very stable, since elements grow vertically if necessary, and the layout does not break when an image is wider than the element, for example. The positioning of items is independent from the source order in HTML.

I am quite enthusiastic about this approach and see many opportunities for it. Feel free to try, experiment and post your comments.

About the Author

Eric Sol

Eric Sol is founder of a small software firm based in beautiful Maastricht, The Netherlands. He has held several positions in Dutch higher education, both in ICT and policy making. He started his journey into CSS in October, 2006. Besides having a family he likes cycling and listening to his collection of vinyl and CDs.

125 Reader Comments

  1. It’s been a while since I’ve seen any new CSS concepts, but this fills the spot perfectly. Thank you. With complex layouts I always end up with what seems like unnecessarily complex CSS, so an additional way of positioning is welcome indeed. Now I just need to clear some time of my schedule to try it out for myself.

  2. This was a good article and I applaud you at your solution, however.

    It seems very much like BluePrintcss which is based on the a grid layout also. It’s also well documented and tested through out the community.

  3. Very intriguing. With every good (and pretty simple) ideea, the first though that arises is: “hmmm, how come i didn’t though of this earlier myself?”

    This really seems to solve some complex layouting problems more easily.

    Thanks for the tip

  4. Very interesting find you and your team did. The technique sounds very promising, and I will definately do some testing. From your article I get the impression that this solves the most annoying problems with the “two other techniques”, and while not being a perfect solution, it works – as long as you are aware of the downsides.

    Good job 🙂

  5. My partner pointed me to your article, and I was just starting to cleaning my messy CSS job for an Joomla site. Well right now I’m thinking of rebuilding the main structure in this way to get all the advantages. I’m not thinking anymore, I’m going to do it if I come across problems of any kind I will let you know.

    Greetings, keep up the good work!

  6. It sounds amazing!

    We are always fighting with positioning and made it fully funtional with all browsers. Always had to use tricks, but this way sounds like a smart solution.

    I will try with a new design…

  7. It seems that this technique possibly could merge some techniques without the cons.

    Will it be the Holy Grail 2.0???

  8. I always enjoy reading about new CSS techniques on ALA and I appreciate the robustness of this solution.

    However, I don’t like the markup. In my opinion, it suffers quite severely from divitis. 3 div’s for a header? No thank you. With lots of nested elements and a bit of CSS and browser knowledge, CSS will always get you there. The trick is to do it with as little unnecessary markup as possible.

  9. It’s looking rock solid. Great!

    Using the second example, I swapped item 6 and item 8 so the written content came nearer the beginning of the html order. It works, it looks exactly the same without having to change the CSS.

    Now, can I move line 2 above line 1…

  10. You mentioned having implemented this technique into a Drupal theme. Is that theme available somewhere? I’d love to have a look as I’m currently designing a Drupal-based site with header/footer/3 columns in between.

    Thanks for the article.

  11. In answer to my own question in #14, yes! Just using position:absolute, width 80% to match the canvas width and margin: 0 auto on line2, with margin-top: 20em on line1 does the trick. So it seems the technique can be mixed and matched, making it very useful indeed 🙂 Well done, Eric!

  12. In #13 Blaise mentioned ‘divitis’. I was fully aware of the need for a lot of structure in the markup. That’s why I mentioned this might not be your method of choice, especially not for simple layouts. However, there is no sound alternative (yet…), no matter how much CSS you throw at it. And, on the upside, the markup is pretty straightforward.

  13. Jason,

    I’ve made an example in Drupal. It’s not a theme ready for a contribution yet. If I can find some time 🙁 I will contribute this.

  14. Interesting read, Eric. Thanks.

    I’ve not tested this yet, but here’s my thumbs up to you (pl.) just for having had that idea.
    I don’t think this will be viable for my work though, as like #13 said, minimum markup is king. 😉

  15. I’d started a redesign of my companies website last week, and had been working with a design where I had two horizontal bars on top, a vertical left hand bar and then a grid of 4 blocks in the main content area, and was running into all of the troubles mentioned. So I get into work today and see this article posted in my RSS feed and was blown away. Needless to say, I adapted this idea to my project and in less than 2 hours, it has taken care of all the problems which I’d been having getting the layout to work.

    As you say Eric, this method is made for designs which are already div heavy, but it’s very flexible. Yeah, you have 3 divs for a header, but if you want to toss a search box, or other content up next to the header, then it’s very easily adaptable to handle that situation.

    Thanks for you guys’ work, and impeccable timing!

  16. I’m always experimenting with various layout techniques but this one is pure gold. With this I can achieve fluid or em widths with a max-width (what I prefer) with ease.

    I also work with Drupal and might have to do something with this. 🙂 Sprinkle in a bit of the theme settings api for user end control.

  17. Oh, and this could be the missing technique that frees BluePrint from pixel width layouts. I’ll have to experiment and combine the ideas.

    Thanks again. I’ve been looking for a solution like this for a looong time.

  18. Negative margin used this way is a hack in itself, although not a browser specific. Positioning is not what the margin is supposed to do.

    This is something I will store in my arsenal for specific situations, but it is definitely not a best practice when it comes to layouts.

    Anyway, It is a good way to get around a whole lot of IE6 bugs.

  19. I want to have a navigation column on the left that spans the lines of content in the middle and right columns. How can I achieve this using your technique?

    Since “canvas” is an id I guess there can only be one per page. Can I embed “line” divs within “sap-content” divs?

    Thanks for sharing your invention.

  20. That’s what Eric meant when he said it was possible to nest faux absolute positioning recursively. The “canvas” id is not special, you can use any other name you want or even use a class you apply to items that should act as a canvas.

  21. Yeah, you can.

    The site I’m working on is now using this layout:

    line: (item, item)
    line: (item)
    line: {item, item: [line: (item, item)], [line: (item, item)]}
    line: (item)

  22. 1. I think that absolute positioning is seldom used amongst serious developers, floats are the norm
    2. The author’s critique of float layouts is narrow and dead wrong
    3. I’ve been coding PSDs, including some exotic ones, and I’ve never had a problem I couldn’t solve with normal techniques.

    But the hacker in me loves that someone has come up with a solution to the problem of having absolute positioning that affects layout. I don’t know how many designs will benefit from the technique though. One nice thing is that it pushes the pixel-perfect absolute-positioning OCD people (never encountered one, or their code, but you know they’re out there!) towards normal layouts.

  23. I am the new web designer for my city’s newspaper (not one of the major cities, but enough to need an in house web designer); only 4 weeks on the job. I needed to make an IE 6 fix for a page. Instead, I noticed the page had the basic elements that could utilize this technique.

    So I rearranged the code and applied this method. It worked perfectly. It even made the CSS in the original cleaner and simpler.

  24. i played with the 2. example and below “min-width” the content is not accessible, because the horizontal scollbar is not visible

  25. For those complaining that this is a case of Divitis, I don’t think it is. Divitis is a result of using DIVs for elements that could use a more appropriate tag, such has H1, UL, etc… I’ve worked with templates that used DIVs for headings and other templates that used lots of nested DIVs with H tags for headings. The latter is perfectly fine and doesn’t interfere with your CSS work.

    The article explains why each DIV is necessary for this technique to work, there’s nothing semantically incorrect here and no harm is done. It’s similar to many of the techniques that allow for rounded corners, it’s something you have to do for a particular method to work.

  26. I’m on xp in IE 7 and about halfway down the page column gets and stays narrow – about 2/3 of the width its supposed to be. If you hover a link in a paragraph with your cursor then IE will redraw the paragraph to it’s correct width.

  27. @Michael Lange (and author of course)

    I tried huge negative margins while searching for what I could call ‘float:center’. You have three elements, all floating and you want them to be centered in the screen. Also on small screens you want the floats to wrap.

    Since float only knows left and right you have no way of doing this without a fixed content width. I made it fixed now, and the wrapping element for small screens is lost.

    When experimenting with a big negative margin, which I though back then might solve the trick (wild guess) I noticed my horizontal scrollbar disappeared, and that made me stear away from any negative margin that extends beyond the canvas.

    If it’s solvable I may use it again, otherwise, I stick to hacks, and the incidental float drop (usually caused by someone inserting a big unbreakable link).

  28. Yes, Ward, it happens in both IE7 & IE6 — I didn’t notice at first because I’m usually browsing with Firefox.

    Eric, what do you intend “sap” to stand for, in e.g. “sap-content”? My brain keeps coming up with things like “somewhat absolute positioning” or “stand alone positioning” or “single apple positron”, and they don’t seem quite right …

  29. The article was great, and I applaud all the work you put into it – I’m happy to seen an alternative to the “other two” options.

    But the fact that you to had to go through this trouble to get a decent layout is sad. It really highlights how inadequate CSS is. No, I don’t want to use tables. I want to see both the CSS standard and browser support improved!

  30. Apologies at ME Curtin: the div with ‘sap-content’ should be called ‘fap-content’. In earlier versions of this article I used the term ‘simulated’ instead of ‘faux’. Still more scrutiny is needed…

  31. It took me a few minutes to understand Ward was taking about the layout of the article, not the examples. Maybe ALA needs faux absolute positioning too 😉 Seriously, I think the conversion from textile to html introduced a bogus
    after the tags. ALA staff: help is needed here…

  32. Michel and Michael are right in concluding this technique will not in itself render a horizontal scrollbar, even if the screen is very small. I think it’s your choice as a designer or developer to let that happen or not. I’ve tested with the ‘small screen’ option in Opera9 and both examples are perfectly usable.

  33. I’m having some issues with this. I have 3 columns, but rather than the content float to the right of each other, they are appearing on separate rows.

  34. It’s been a while since a piece of coding has me this excited. I had previously been using the float technique and fiddling with margins to get everything to sit right. I’m a big fan of grid layouts so this technique is perfect for a lot of my projects and will save me endless amount of hours…

  35. I think the better solution to distribute columns is to use a padding-left on all columns and remove on the first, like that:

    .column {padding-left:20px}
    .column:first-child {padding-left:0;)

    I prefer to use :first-child rather than :last-child because it’s more compatible.

  36. Great article.

    This is a great technique and I will definitely be using it in future. I’m not sure it’s completely new though. Haven’t negative margins and relative positioning been “used before”:http://www.bluerobot.com/web/css/center2.html ?

    And of course the columns are still _faux columns_. A better solution would be to use display:table-row and display:table-cell but of course that doesn’t work in any of the main browsers.

  37. I’ve done a lot of playing around with this and found it surprisingly reliable and easy to implement into an existing site. I love the fact that the order of the items in a line has no significance, so you can put the content in front of the sidebars without repercussions.

    The CSS is minimal and easy to remember, although it doesn’t make any sense to me, but that’s not the point. 🙂 I’m going to try implementing this into our own Drupal theme.

    Thanks Eric and Co.

  38. I just wanted to drop some kudos for this technique. It happens to apply to exactly what I was struggling with this morning. Thanks!

  39. Running FX 2.0 on Windows Vista, and i ran into a content problem. On window resize, the content keeps it’s place, does not move along with it’s container. A refresh solves the problem. IE6, IE7, IE8, Opera 9.5 And Safari for Win work just fine as i tested.

    It is a nice solution, but sounds kind of “hacky” to me. Usually i use the float technique, which seems to be a little more stable than this one. Never got in any trouble. I’ll definetly study this one and maybe use it if the need appears, but i won’t replace my old technique until i am familiar with all the drawbacks of this one.

    Thanks a lot for the beautiful article.

  40. To describe even better the problem: 3 columns, left:30%, right: 20%. Content stays in place on window resize. Now, this only affects this type of layout. If instead i have px defined widths for the left and right, all works just fine.

  41. Thanks for letting us know. All fixed now.

    Funny story. A carriage return in the code examples caused IE6 and IE7 to furiously self-mutilate. There was nothing wrong with the carriage return, of course. But IE6 and IE7 have, shall we say, a bizarre relationship with whitespace in HTML.

  42. Thanks for all the positive feedback so far. It’s great to know this really is helping people.
    @Christain: I’m not able to assist with implementation issues right now, hope to spare some time later this week – have to earn some money sometime… I would rather say the standards are ‘underspecified’; the technique is not ‘hacky’ since it complies.

  43. No problem at all. I’ll try to investigate this as soon as i have some spare time. I gotta earn money too. As for the hacky thing, it’s between brackets. I was not expressing a point of view based on the current css specs but rather a personal point of view. Either way, as i said, great article snd promising technique. Hopefully Those minor problems will be solved.

  44. Hi, you say that “you cannot calculate the margin-left because you never know how many ems fit in 800 pixels” but there is an easy way around this. If you make the font size of the body 62.5% then 1em=10px. This makes it easy to make such calculations. Clearly, this is best done at the start of a site design, as it will affect all of the font sizes in the site! But, it is a good part of varnish-stripping and a useful technique to use anyway.

  45. Milburn Thomas wrote in comment 42: _”And of course the columns are still faux columns. A better solution would be to use display:table-row and display:table-cell but of course that doesn’t work in any of the main browsers.”_

    Even better would be CSS Columns supported in all browsers. Then we wouldn’t need any complex layout techniques at all.

  46. The main advantage it seems to me for this technique is the use of overflow:hidden, but using overflow:hidden on floated elements would make them behave like absolutely positioned elements. Is there something I am missing?

  47. I noticed that if you add a min-width rule ( desired min-width + widths of left and right columns ) to the content div it keeps the center content from being completely collapsed when the browser window gets small…

  48. Hi,

    I tried both examples in IE6. In the first case, when the width of browser is reduced, the middle column disappears. In teh second example, on reducing width, some text in the middle column is lost.

    I am looking for an elastic 2/3 column layout with header/footer that does not collapse when height/width is minimised…

  49. In the first example, when you make the canvas smaller than the combined width of the left + right column, the middle column *should* disappear, since the width of this column is the remaining width. If you don’t want that to happen you should use other dimensions, like 30%-40%-30%.
    In the second example, remember the items have ‘overflow: hidden’. Therefore, words that are wider than the item itself seem truncated.
    All of this is expected behaviour that is easily adapted, e.g. use ‘min-width’.

  50. It’s always a bit of a bear to stare a complex grid-based layout in the face (read: anything elastic or fluid). This looks like it will take the bite out of grid-based layouts. Thanks!

  51. I admire the ingenuity of this scheme. Stepping back though, I wonder if folks have an opinion as to whether this line/item scheme is superior to tr/td. From a semantic standpoint I’d say “no, they are equivalent”?. Does this give us some great gain in layout ease or flexibility versus tables?

  52. Well, given MS Word’s poor handling of positioning and float, it’s no surprise that this technique is completely mutilated by Outlook ’07. It might look better in Outlook ’03 or ’00, though, since those versions use the IE rendering engine….

    Sadly, it’s back to tables for us email designers ):

  53. I came across the comparision with table based design a couple of times, especially from people complaining about ‘divitis’. I think faux is superior over tables for a number of reasons:

    * faux does not require the same amount of items in every line, like you have using td’s in tr’s (there’s no such thing as colspan here!), therefore the markup is more efficient and clean
    * faux gives far greater flexibility in handling what each cell ought to do compared to the rather rigid way tables are rendered
    * it complies with standards – using tables for layout does not
    * it eliminates a lot of the crossbrowser whitespace issues; tables do not

    Remember this technique is mostly suited for grid-based designs. You have to define a grid, which by definition implies rows and columns. But the flexibility is far greater.

    So Outlook ’07 messed it up. What else is new? Sigh….

  54. Interesting approach. The toolkit is never full. I like.
    However – and I hope I’m not committing a faux pas here – the title seems a bit pretentious and, worse, misleading. Faux means “fake” does it not? Nothing fake here. And the author isn’t even French.
    Take your pick:
    Simulated Absolute Positioning
    Imitation Absolute Positioning
    Artificial Absolute Positioning
    But if we must go European, how about the old chestnut:
    Ersatz Absolute Positioning

    Sorry, I couldn’t help myself. Good article.

  55. Er… it’s broken in *outlook*? When did it become a good idea to put CSS positioning (let alone other CSS) into HTML email?

  56. Great discovery Eric! Thank you for sharing it!
    I will surely test it and tell you if there’s something wrong in a specific case…

    One question: you put display: block; on .line, why?
    To use the same class again somewhere on other non-block elements or what?

    is block by default. I removed it and couldn’t find any difference in FF, IE6 + 7, and Safari/win.
    I’m eager too know why you put it for.
  57. Is display: block necessary on

    since that is already a block-level element?


  58. You folks are right: the display block is not necessary at all, it is a leftover from earlier experiments. Sorry for the confusion.

  59. I work at an internet development company and i had the very problem this article talks about. I did not want to use tables to create the layout of the main part of the page. After i read this article i immediately applied the concept and it took care of any problems i had and imitates the old table look exactly and after all this is the result i wanted.

  60. Following the same concept, I had no problem getting this to work with fixed pixel width columns. Tests across FF2, FF3, IE7, IE6, Opera and Safari. If this continues to hold up through various testing, this will be great, as there’s no more footer clearing issues.

  61. @”Peter Labrow”:”http://alistapart.com/comments/fauxabsolutepositioning?page=6#53″ :

    bq. If you make the font size of the body 62.5% then 1em=10px

    This is only true if the user’s default font size is 16px. Yes, it’s going to work most of the time, but you can’t count on it. Even adjusting the font size while on the page (e.g., Command-+) will affect how many pixels correspond to 1em.

    It’s generally safest not to mix relative units (em, ex, percent) with absolute units (px, pt).

  62. Thank you for this article, but I would still recommend, above this technique, the table.

    Now, before you assume that I must be a (1) newbie or (2) Philistine, know that I am a (1) professional web programmer and (2) lover of theory over practicality (to see that, read “this”:http://combatentropy.com/coming_back_to_the_table )

  63. In my experience tables have caused more pain than DIVs due to the restraints in layout changes and numerous white space issues. But maybe it’s just me. 🙂

  64. Thanks for the great technique. I’ve just successfully implemented it on “my blog”:http://mark.tranchant.co.uk after painfully figuring out that:
    * “Movable Type”:http://www.movabletype.com already uses the .item class, so I needed to change the name;
    * Mis-spelling the replacement item class name on one of the items causes horrific, confusing errors.

    I’m looking forward to the next time I need to make a complex form, so I can try using it there.

  65. It’s nearly impossible to ask Designers to design within a grid. As I’d love to use Blueprint CSS, it doesn’t always work very well when the Designs I slice and code are 900px wide with random layouts. Not to mention they require fixed font sizes, complex gradients and stuff you wonder… why not just Flash?

    Frankly, tables never work as well as they theoretically could. They don’t make anything “faster” and usually create a lot of bloat. I do use tables for… tabular data. That makes perfect sense. But not for containing layout.

    Also, I checked all the examples from the article on the iPhone, and looks good! Something to consider using. However, I’m usually looking for the fastest way to do something best. If I could only convince more Designers to use a grid…

  66. “The content of the boxes may overlap (depending on other variables such as overflow: hidden) but that’s all—and in our view, it’s better to risk overlap than risk breaking the whole layout.”

    I think it’s better if the layout breaks, but the content is still visible. For example, if a user zooms text due to issues with impaired sight then overflow:hidden will chop the content. Otherwise it’s style over substance.

  67. @Mark Tranchant – Your’re page is not rendering the HTML properly (as in I can see only the HTML).

    Always been slightly concerned about using overflow:auto though in case of any scrollbars appearing randomly. I couldn’t spot any with this technique though so very promising 🙂

  68. I tried it and it works flawlessly. This already saved me from a lot of bugfixing especially in IE6. I can also say that in many cases it takes less time to change a simple existing float to fauxabsolutepositioning, than to look for a way to solve some IE bugs. Thanks again.

  69. I used your technique along with a slantastic 🙂 layout created by Eric Meyer. I had to use your technique because of the way the slantastic layout was created if you get a chance I would love to hear your response. Thank you.

    P.S. While some people are trying to call your new technique not worthwhile im almost positive they did not understand the reason you created it. It wasnt necessarily for people who already knew everything they needed to know but for those individuals who needed a solution to a common problem with both of these positioning techniques. Thank you.


    That is where to find the layout and i would love to hear your response. Thank you.

  70. @Mark: You can’t do that directly, but you can play with the height and top of elements or you can use nesting (creating an item that itself acts as a canvas to contain two or more rows) to achieve the same effect. It would take some puzzling, but it’s definitely doable.

  71. Hoi Eric!

    Very interesting, and nice way of thinking. I`d really like to see some sites built using this method.. to see if we can break them! 🙂

    Good work fella.

  72. I decided to make the site im working on, which is my personal site it isn’t much but its still getting settled, available and looking decent in ie 6. I used this technique just because i didnt feel like changing all the markup just the minor parts of the css. It worked great in the site i was working on. If anyone wants to get in touch with me i have a working form on the site.


  73. While using this technique the past week I couldn’t help to think I had a case of divitis. Seems like quit a bit of presentational mark-up is needed in order to get the end result.

    However, that aside I applaud your discovery.

  74. This is what it was made for.. to simulate a grid layout without using tables. Todd, divitis is when you are using divs for everything.. a prime example is navigation containing solely divs. The presentational markup is not existent. He is using a div basically for each ‘cell’ to create the effect. What you are also pointing out was pointed out in a prior post. I think Eric wanted to do what he could while using standards based code. Tables are for tabular data.

  75. I’ve been designing hardware and software for thirty years now. I think I have a track record of dealing with complexity. I’ve tried on and off to use CSS and succeeded as long as I keep it real, real simple.

    I’ve been trying to implement a simple version of this technique for the past two hours. I’ve read the article several times, top to bottom. The example in the text shows only one item so it does not match the diagram which has three items. When I look at example one it is so full of other classes, IDs and HTML markup for forms that I have not been unable to separate the wheat from the chaff.

    I wish the author had presented a grid with one line containing one item and a second line with two items and then a third line with three items. Then I think I could perhaps have been able to reverse engineer how the margin percentages interact and other parameters interact and then be able to extrapolate how to modify them for my own use.

    Sorry to carp so much. This article was intended to present a technique for those already skilled with CSS. I think I’ll just go back to using tables to line things up the way I want them. It may not be semantic but at least it works for me.



  76. Great Article – I just recoded a site with which I had some problems. Unfortunately (for me) text is not visible in DWCS3 or DWCS4 beta Design View. I validated my CSS and HTML at W3C and all validated. We use DWCS3 to quickly paste text to templates so functionality in DW is important.

    It appears that DW does not like the negative margins as it appears that the content is off to the left of the design view window. I can get it back if I temporarily modify the style sheet or the html but that’s not really helpful.

    If anybody has any suggesions I’d appreciate seeing them.

  77. Divitis is indeed the first impression users seem to get when trying this… but if you use the principles and adapt the code a little, its a very easy, very adaptable system.

    For eg, you dont need to put

  78. list1
  79. any divitis there? Nope.

    We`ve used this at work, and everyday we find something new and impressive with the way it stands up to moulding and shaping of the code.

    Good work fella!

  80. Robert, i can help explain the principle if you want. I can see how it can be confusing to get your head around, but once you’ve got it, it really is very useful.

    I tried to find an email address through your website, but couldnt. Let me know if you need a hand.

  81. Robert, i can help explain the principle if you want. I can see how it can be confusing to get your head around, but once you’ve got it, it really is very useful.

    I tried to find an email address through your website, but couldnt. Let me know if you need a hand.

  82. I love this technique, although I know there are some arguments against it (google faux positioning). In fact I love it so much that the new base theme for Drupal I’m making is based on this technique and it works great! In the first website I did with this base theme I’m having a problem, when I added a table of contents that uses same pahe links, whenever I clicked on a section all of the content in the main div that came before it, dissappeared. If I give overflow:scoll just to the main div, I get a scrollbar in the div and I can see the content scrolling up. This is pretty much a deal braker for that particular theme I’m building because I really need table of contents because of the amount of content the pages in the site has. Is there any way to be able to use this technique with table of contents?

  83. I can confirm that Rafael is correct with the fact that in IE6 a background image on one of the main ‘columns’ (item) will throw off the layout completely. Mousing over a link snaps the columns back to where they should be, but obviously that’s no solution.

    For now the best solution I can find is to put the background image on an element within the column/item instead.

    Strangely, using a background _colour_ doesn’t cause the same glitch.

  84. Nice article and interesting technique! Just one minor typo:

    bq. [I]t lets us play with @position: overflow@ (without breaking the grid!).

    My first impulse is always to doubt myself, but I’m sure that’s not a legitimate value for this property! 🙂

  85. from the examples: scales poorly past a certain point. or was this just in the examples?

  86. I have used this to redo the css for a site that went live earlier this year,

    My only problem is I cannot work out how to stop the menu in the left hand column from being displayed. Ive tried

    #sidebar-left.item column, #ddblueblockmenu
    display: none;

    and various combinations but it still gets printed . Any ideas

  87. This is awesome! I just starting fooling around with it and I can already see how efficient this is. Thanks for the article!!!


  88. I really just wanted to make a simple personal site. But the complexity of doing just the simplest of things have such a myriad of choices that I just want to throw my hands up in the air and scream. I thought CSS was to be a universal solution that would enable once and for all the ability for everyone to be on the same level playing surface. But as it turns out, for every solution there is 10 opinions that state the opposite or the same but different approach. I see why even though FrontPage was so hated by so many, that it really made things simple. That is, until we went to Expression versions. I guess at least everyone is in the same but different bucket of confusion. Ultimately, I guess my question is: have we really come that far? Just seems like everyone is just arguing a new subject, but in reality it just the same old stuff – no one agrees on anything. Why has CSS made everything so complex? When its original intent was to simplify. Maybe we should all start from scratch again!

  89. There will be a problem when I add a background-image to that DIV in IE 6. All DIVs that contain a bckground-image will be kept in the right and not in the correct position.

    Do you have any method to solve this bug?

  90. Thank you for publishing this great tip!! I’ve been trying to implement tableless CSS design and this makes it so much easier. Keep the great tips coming!

  91. Thanks for sharing this concept. It is very interesting for me as I used to spent hours fixing some broken css layouts in IE 5 & 6. I will try this layout technic in one of my next projects.

  92. This is a phenomenal technique, but I’ve run into an issue that a few others have mentioned. To reproduce this error, use a background-image on an element with class-name “item” and see how IE6 reacts.

    It appears that this is a “Peek-a-boo bug”:http://www.positioniseverything.net/explorer/peekaboo.html – the element is invisible when you load/reload the page, but suddenly reappears when you resize the browser window.

    I tried to use the “clearfix”:http://www.positioniseverything.net/easyclearing.html approach to no avail and ended up refactoring my layout to make use of the sap-content element for background images.

    Hopefully this extra info will help someone smarter than myself to find a more robust solution.

  93. I’ve been building websites for years and consider myself pretty nifty with CSS, but a method like this just never occurred to me! It looks robust and pretty straight forward and I’ll deffinitely give it a try next time I need to do a reasonably complex layout. Cheers guys!

  94. That’s an awesome job at problem solving…I’ve wondered how to do something similar to this for awhile, because I hate using tables for layouts because they’re slow-loading, and with divs I felt like I was stuck into only creating 2 column-layouts for fear of creating broken layouts if the elements end up growing too much or the padding/margins aren’t quite the same for every browser. Good solution.

  95. I’m very intrigued by this approach, and so far testing it against various browsers has worked fine… except for one IE6 (?) glitch: when using a two-column layout with Faux Absolute Positioning, and IE6 is running on a Virtual PC, the left column frequently (but not always) gets displayed to the far right. For more info see: “Anyone seen image positioning problems with IE6 running on a Virtual PC?” on MSDN IE Web Dev forum…

  96. My IE6 layout problem had already been reported (although apparently not yet completely resolved). I must have accidentally jumped past those posts…

    But knowing that it’s aggravated when running under VPC may shed some light on how someone (smarter than me) might come up with the best work-around.

  97. Nice article, and nice techniques. I haven’t sen this approach before, and I will try it out.

    I’ve been wondering similar things when it comes to multi-column layouts, and I have an idea that I’ve been using that I’d lke to run past you, or anyone else.

    I’ve been using elements with the CSS display: inline-block. In combination with the vertical-align: top; property, I can achieve something very much like two or three table cells sitting next to eachother in a row, since they are sitting on the same text baseline (inline) but can take width properties (block). It’s a nice combination of the two.

    The problem is, if you stick a DIV inside of these spans, the layout will not validate. Since Spans are default inline, is it not allowed to insert a block-level div inside of them. The reason why I use Spans in the first place is that as early as v5, inline-block is supported in IE only on elements that are by default inline. So, spans, anchors, img tags, etc… can be inline-block, but DIVs can not.

    So, the question is, while this is a powerful layout tool, is it off limits since it technically is not allowed? Will the inline-block property eventually go the way of the dodo and cease to be supported?


  98. Hi Eric!
    I have stumbled upon this technique while looking for a solution to my problem. I am still not sure if/how I can use it. I think you may have had the same issue. The users have a “screen designer” for a form layout. I need to replicate that in the browser. Now it’s done with absolute positioning, and the problem is that the footer, which comes right after the form’s content, now gets placed to the top because of absolutely positioned elements in the form that don’t provide the form with a height. Can I move the footer in it’s place by still positioning the elements inside the form in the same positions the user did? If so, how. I seem to not getting exactly the point.

Got something to say?

We have turned off comments, but you can see what folks had to say before we did so.

More from ALA