<div id="outer"> <div id="inner"> <div>!</div><p>this is any element of any width</p> </div> </div>
/*-- for show only -- */ #outer { border: 1px solid black; } #inner { border: 1px dotted red; } /*-- all you actually need -- */ #outer { text-align: center; } #inner { display: inline-block; }