How to align a to the middle (horizontally/width) of the page [duplicate]

I have a div tag with width set to 800 pixels. When the browser width is greater than 800 pixels, it shouldn’t stretch the div, but it should bring it to the middle of the page.

27 s
27

<body>
    <div style="width:800px; margin:0 auto;">
        centered content
    </div>
</body>

Leave a Comment