<div id="wrapper" style="text-align:center"> <div id="wrapped" style="display:table;margin-left:auto;margin-right:auto;text-align:left"></div> </div>
WFM YMMV
Why not? The goal is to center something with an unpredictable size.
display:block adapts to the container. display:table adapts to the contents.
This uses both.
Cool. Thanks!
It was sort of HTML-pseudocode.
In any case, this is exactly how you center something that doesn't try to stretch across the entire page. It's old-fashioned, but robust.
Also, I would generally not use inline CSS. I think of it like I think of !important: the nuclear option.
That said, I tend to use inline styles a lot for WordPress site content, because I don't want to deal with the slow-ass "customize" option.
<div id="wrapper" style="text-align:center"> <div id="wrapped" style="display:table;margin-left:auto;margin-right:auto;text-align:left"></div> </div>
WFM YMMV