{"id":157,"date":"2008-06-28T13:10:58","date_gmt":"2008-06-28T18:10:58","guid":{"rendered":"http:\/\/cssnewbie.com\/?p=157"},"modified":"2008-06-28T13:10:58","modified_gmt":"2008-06-28T18:10:58","slug":"argument-against-faux-absolute-positioning","status":"publish","type":"post","link":"https:\/\/cssdeck.com\/blog\/argument-against-faux-absolute-positioning\/","title":{"rendered":"An Argument Against Faux Absolute Positioning"},"content":{"rendered":"<p><a href='http:\/\/alistapart.com\/articles\/fauxabsolutepositioning'><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/cssdeck.com\/blog\/wp-content\/uploads\/2008\/06\/faux-400.gif\" alt=\"\" title=\"faux-400\" width=\"400\" height=\"120\" class=\"alignnone size-full wp-image-159\" \/><\/a><\/p>\n<p>A week or so ago, Netherlands-based <a href=\"http:\/\/alistapart.com\/articles\/fauxabsolutepositioning\">Eric Sol published an article on <em>A List Apart<\/em><\/a> titled \u201cFaux Absolute Positioning,\u201d where he outlines a new system of element positioning that he has developed. Shortly afterwards, a reader wrote to me and asked my opinions on the technique. In the spirit of <a href=\"http:\/\/cssnewbie.com\/list-based-css-calendar\/\">continuing the fantastic conversations we\u2019ve been having on CSSnewbie<\/a> recently, I thought I would respond publicly so that others might have the option of offering their opinions as well. But if you haven\u2019t read <a href=\"http:\/\/alistapart.com\/articles\/fauxabsolutepositioning\">Eric\u2019s article<\/a> yet, please do so before responding, so you have the full picture and not just my interpretation of things.<\/p>\n<p>Mr. Sol\u2019s development of the Faux Absolute Positioning technique was born of frustration in trying to use the two dominant positioning techniques: <a href=\"http:\/\/cssnewbie.com\/harnessing-positioning-1\/\" title=\"Harnessing CSS Positioning\">absolute positioning elements,<\/a> and floating elements. His argument against using absolute positioning for page layout is that it causes any containing elements to collapse (because the element is pulled out of the document flow), which can cause all sorts of problems. This, I will entirely agree with. <\/p>\n<p>However, his argument against using floated elements is that content changes can cause the width of the element to change, which can in turn wreak havoc on float-based layouts. This is partially true. Left to its own devices, for example, a 500 pixel wide column containing a 550 pixel wide image will probably ruin a float-based layout. However, in practice simply applying a rule of \u201coverflow: hidden\u201d to that column would have eliminated any column-resizing problems in nearly all cases, simply cutting off the side of the image when it reached the edge of the column. And considering that using Faux Absolute Positioning relies on an understanding that \u201cthe content of the boxes may overlap,\u201d but that \u201cit\u2019s better to risk overlap than risk breaking the whole layout,\u201d I don\u2019t understand what makes using \u201coverflow: hidden\u201d on floated elements so detrimental or different.<\/p>\n<p>But that isn\u2019t my real concern with Eric\u2019s argument for the technique. I\u2019m most concerned with the XHTML structure required to actually <em>implement<\/em> the technique. As I\u2019ve mentioned before, <a href=\"http:\/\/cssnewbie.com\/deprecated-element-highlighting\/\" title=\"Find Deprecated Elements with Diagnostic CSS Highlighting\">I\u2019m a bit of a code purist.<\/a> I believe in using the least amount of code to the greatest effect, and this is especially true when it comes to XHTML. A CSS file can be cached and reused by the browser over an entire website, reducing the strain on a user\u2019s bandwidth. However, each new page a user visits requires them to download an entirely new XHTML page, regardless of how similar that page is to the previous one they visited. In my mind, this is the strongest argument behind switching from presentation-heavy HTML (tables, font tags, etc) to semantic XHTML (and using CSS for presentation) in the first place.<\/p>\n<p>Because of that, I wince when I see the XHTML used to implement the Faux Absolute Positioning technique. Take a look at the sample offered:<\/p>\n<pre lang=\"html4strict\" escaped=\"true\" line=\"1\">&lt;div id=&quot;canvas&quot;&gt;\n  &lt;div class=&quot;line&quot;&gt;\n    &lt;div class=&quot;item&quot; id=&quot;item1&quot;&gt;\n      &lt;div class=&quot;sap-content&quot;&gt;content here&lt;\/div&gt;\n    &lt;\/div&gt;\n  &lt;\/div&gt;\n&lt;\/div&gt;<\/pre>\n<p>Does that structure look strangely familiar? It should \u2013 it\u2019s a table, converted into divs. The \u201ccanvas\u201d div functions as the table container, while the \u201cline\u201d class of divs acts as rows and the \u201citem\u201d divs behave as table cells. In fact, this technique actually uses an <em>additional<\/em> div (\u201csap-content\u201d) inside of each \u201ccell,\u201d bloating the code even further. Compare it to this table-based reimplementation: <\/p>\n<pre lang=\"html4strict\" escaped=\"true\" line=\"1\">&lt;table id=&quot;canvas&quot;&gt;\n  &lt;tr class=&quot;line&quot;&gt;\n    &lt;td class=&quot;item&quot; id=&quot;item1&quot;&gt;\n      &lt;div class=&quot;sap-content&quot;&gt;content here&lt;\/div&gt;\n    &lt;\/td&gt;\n  &lt;\/tr&gt;\n&lt;\/table&gt;<\/pre>\n<p>Now, I understand that there is a semantics argument to be made here. Mr. Sol probably didn\u2019t want to use a table because, semantically speaking, a table should contain tabular data and nothing more. But the problem is, the Faux Absolute Positioning technique simply <em>reimagines tables<\/em> using divs and classes rather than \u201ctr\u201d and \u201ctd\u201d tags. <\/p>\n<p>The real benefit of the technique, Eric states, is that &#8220;we can align every item to a predefined position on the grid [&#8230;] but items still affect the normal flow,&#8221; and his  insistence on thinking of elements in a page as \u201ccells in [a] grid\u201d is telling: the author really just wants to use a table, but can\u2019t justify it semantically. Thus, he develops a \u201csemantic\u201d alternative that, instead of suffering from non-semantic code, suffers from <a href=\"http:\/\/cssnewbie.com\/combating-classitis\/\" title=\"Combating Classitis with Cascades and Sequential Selectors\">divitis, classitis, and code bloat<\/a> instead.<\/p>\n<p>I wrote an article a couple of weeks back on <a href=\"http:\/\/cssnewbie.com\/list-based-css-calendar\/\" title=\"A Semantic List-Based CSS Calendar\">building a calendar using lists instead of tables<\/a> that ended up sparking a great deal of thoughtful debate of the nature of calendars, the semantic meaning of tables, and the overuse of lists in modern web design. I plan to respond to that debate more fully next week in a separate article, but one point I plan to make then is worth mentioning now: I believe in using semantic code wherever possible, but I also believe in <em>minimizing<\/em> code wherever possible. One of the (several) reasons I was so intrigued by the possibility of a list-based calendar is that I knew I could create it with less XHTML than a table-based calendar would require, reducing the bandwidth costs of whatever website it was implemented on. <\/p>\n<p>The Faux Absolute Positioning technique, by contrast, requires <em>at least as much<\/em> XHTML as an equally complex table would require, and may actually require significantly <em>more<\/em> code because of the additional div inside each \u201ccell.\u201d Depending on the complexity of the site using this technique, we could be talking about 15% greater bandwidth costs on every single page of the website, compared to an identical site using a table for layout. Admittedly, the website could still tout a \u201ctable-less\u201d design, at least in the narrowest definition of the phrase. But because of its insistence on rows, columns, and a clearly defined grid, it is at least a table in spirit, and may in fact be more complex and weighty than a table would be in practice. And if a designer is utterly committed to having the rows, columns, and cell-based grid that this technique permits, I would argue that the table tag deserves a second look, if for no other reason that to reduce page size.<\/p>\n<p>At the end of the article, the author does admit that this technique is probably only sufficiently rewarding to be used on rather complex page layouts. But if a site\u2019s layout has reached the level of complexity wherein the only viable options are to use a table to create a grid or <em>reinvent<\/em> a table to the same end, perhaps it\u2019s the design of the site, and not the code behind the site, that should be reconsidered.<\/p>\n<p>Now, I don\u2019t want to be seen as attacking Mr. Sol\u2019s person or work. I respect the amount of time it must have taken to develop the Faux Absolute Positioning technique and the ingenuity that went into the CSS. My goal here is to simply encourage a debate on the subject. And now that I\u2019ve had my say, I would love to hear what you think about all this.<\/p>\n<div class=\"wp-socializer wpsr-share-icons \" data-lg-action=\"show\" data-sm-action=\"show\" data-sm-width=\"768\" ><h3>Share and Enjoy !<\/h3><div class=\"wpsr-si-inner\"><div class=\"wpsr-counter wpsrc-sz-32px\" style=\"color:#000\"><span class=\"scount\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"facebook,twitter,linkedin,pinterest,print,pdf\">0<\/span><\/span><small class=\"stext\">Shares<\/small><\/div><div class=\"socializer sr-popup sr-32px sr-circle sr-opacity sr-pad sr-count-1 sr-count-1\"><span class=\"sr-facebook\"><a rel=\"nofollow\" href=\"https:\/\/www.facebook.com\/share.php?u=\" target=\"_blank\"  title=\"Share this on Facebook\"  style=\"color: #ffffff\" ><i class=\"fab fa-facebook-f\"><\/i><span class=\"ctext\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"facebook\">0<\/span><\/span><\/a><\/span>\n<span class=\"sr-twitter\"><a rel=\"nofollow\" href=\"https:\/\/twitter.com\/intent\/tweet?text=%20-%20%20\" target=\"_blank\"  title=\"Tweet this !\"  style=\"color: #ffffff\" ><i class=\"fab fa-twitter\"><\/i><\/a><\/span>\n<span class=\"sr-linkedin\"><a rel=\"nofollow\" href=\"https:\/\/www.linkedin.com\/sharing\/share-offsite\/?url=\" target=\"_blank\"  title=\"Add this to LinkedIn\"  style=\"color: #ffffff\" ><i class=\"fab fa-linkedin-in\"><\/i><\/a><\/span>\n<span class=\"sr-pinterest\"><a rel=\"nofollow\" href=\"https:\/\/www.pinterest.com\/pin\/create\/button\/?url=&amp;media=&amp;description=\" target=\"_blank\"  title=\"Submit this to Pinterest\"  style=\"color: #ffffff\" data-pin-custom=\"true\"><i class=\"fab fa-pinterest\"><\/i><span class=\"ctext\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"pinterest\">0<\/span><\/span><\/a><\/span>\n<span class=\"sr-print\"><a rel=\"nofollow\" href=\"https:\/\/www.printfriendly.com\/print?url=\" target=\"_blank\"  title=\"Print this article \"  style=\"color: #ffffff\" ><i class=\"fa fa-print\"><\/i><\/a><\/span>\n<span class=\"sr-pdf\"><a rel=\"nofollow\" href=\"https:\/\/www.printfriendly.com\/print?url=\" target=\"_blank\"  title=\"Convert to PDF\"  style=\"color: #ffffff\" ><i class=\"fa fa-file-pdf\"><\/i><\/a><\/span><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Mr. Sol\u2019s development of the Faux Absolute Positioning technique was born of frustration in trying to use the two dominant positioning techniques: absolute positioning and floats. However, I fear his cure might be worse than the disease. [&#8230;]<\/p>\n<p><a class=\"more-link article\" href=\"https:\/\/cssdeck.com\/blog\/argument-against-faux-absolute-positioning\/\" title=\"Click to read 'An Argument Against Faux Absolute Positioning'\">Read Article<\/a><\/p>\n","protected":false},"author":18,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[166],"tags":[205,240,260,323,334,130],"_links":{"self":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/157"}],"collection":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/comments?post=157"}],"version-history":[{"count":0,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/157\/revisions"}],"wp:attachment":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/media?parent=157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/categories?post=157"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/tags?post=157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}