1

I came upon an example which allows vertical and horizontal centering of a div. See their jsFiddle.

I noticed that it only works if the html/body is set to display: table and the width and height are set. Are there any downsides to setting the display on the entire html/body to table?

html, body {
    width: 100%;
    height: 100%;
    display: table;
}
iheartcsharp
  • 1,279
  • 1
  • 14
  • 22
  • http://www.sitepoint.com/forums/showthread.php?597136-CSS-display-table-Pros-and-Cons-for-layouts – coder hacker May 05 '14 at 15:54
  • possible duplicate of [Why not use tables for layout in HTML?](http://stackoverflow.com/questions/83073/why-not-use-tables-for-layout-in-html) – TylerH May 05 '14 at 15:57
  • I don't think this is a duplicate. My question is about setting display: table on the body and its reprecussions, where as the dupe link is about using tables for layout purposes. – iheartcsharp May 05 '14 at 16:01
  • If you only have one main piece of content on the whole page that you want to display centered, then I’d say there’s nothing much that speaks against this approach. If you have other pieces of content as well, this approach might prove more troublesome though. – CBroe May 05 '14 at 16:29
  • I can better answer your question if you let me know what are you trying to accomplish by using display:table. – Spanky May 14 '14 at 18:07
  • @Jimmy, I'm doing it differently right now, but I was just wondering how the layout would be affected if you set the body to display: table. – iheartcsharp May 14 '14 at 18:45

0 Answers0