Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Bootstrap Image Alignment</title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"></script> <style> /* Custom CSS to beautify this example */ .box{ padding: 15px; border: 4px solid #666; margin-bottom: 20px; } </style> </head> <body> <div class="m-4"> <h4>Left alignment (This is default)</h4> <div class="box"> <img src="/examples/images/avatar.svg" alt="Sample Image"> </div> <h4>Center alignment using text alignment classes</h4> <div class="box text-center"> <img src="/examples/images/avatar.svg" alt="Sample Image"> </div> <h4>Right alignment using text alignment classes</h4> <div class="box text-end"> <img src="/examples/images/avatar.svg" alt="Sample Image"> </div> <h4>Horizontal alignment using float classes</h4> <div class="box clearfix"> <img src="/examples/images/avatar.svg" class="float-start" alt="Sample Image"> <img src="/examples/images/avatar.svg" class="float-end" alt="Sample Image"> </div> <h4>Center alignment of block-level image using auto margin</h4> <div class="box"> <img src="/examples/images/avatar.svg" class="d-block mx-auto" alt="Sample Image"> </div> </div> </body> </html>