Use text-align: center for the container, display: inline-block for wrapping the div, and display: inline for the content of the div for the horizontal center of the content with an undefined width in browsers:
<!doctype html> <html lang="en"> <head> <style type="text/css"> .wrapper { display: inline-block; } .content { display:inline; } .container { text-align:center; } @media, { .wrapper { display:inline; } } </style> <title>Horizontal Centering Test</title> </head> <body> <div class="container"> <div class="content"> <div class="wrapper"> test text </div> </div> </div> </body> </html>
Paul Sweatte Jun 20 2018-12-12T00: 00Z
source share