How to align a to the middle (horizontally/width) of the page [duplicate]
<body> <div style=”width:800px; margin:0 auto;”> centered content </div> </body>
<body> <div style=”width:800px; margin:0 auto;”> centered content </div> </body>
Below is the best all-around solution I could build to vertically and horizontally center a fixed-width, flexible height content box. It was tested and worked for recent versions of Firefox, Opera, Chrome, and Safari. .outer { display: table; position: absolute; top: 0; left: 0; height: 100%; width: 100%; } .middle { display: table-cell; vertical-align: middle; … Read more
Warning! This answer is too old and doesn’t work on modern browsers. I’m not the poster of this answer, but at the time of writing this, this is the most voted answer by far in both positive and negative votes (+1035 -17), and it’s still marked as accepted answer (probably because the original poster of … Read more
Actually, in this case it’s quite simple: apply the vertical align to the image. Since it’s all in one line, it’s really the image you want aligned, not the text. <!– moved “vertical-align:middle” style from span to img –> <div> <img style=”vertical-align:middle” src=”https://via.placeholder.com/60×60″ alt=”A grey image showing text 60 x 60″> <span style=””>Works.</span> </div> Tested … Read more
Basics For controlling “cellpadding” in CSS, you can simply use padding on table cells. E.g. for 10px of “cellpadding”: td { padding: 10px; } For “cellspacing”, you can apply the border-spacing CSS property to your table. E.g. for 10px of “cellspacing”: table { border-spacing: 10px; border-collapse: separate; } This property will even allow separate horizontal … Read more