center image and text inside a block - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Image Text

Description

center image and text inside a block

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
.block {<!--   ww  w .  j  av  a 2  s  . co  m-->
   text-align:center;
   height:401px
}

.block:before {
   content:'';
   display:inline-block;
   height:100%;
   vertical-align:middle;
   margin-right:-0.26em;
}

.centered {
   display:inline-block;
   vertical-align:middle;
}

.left {
   float:left;
}
</style> 
 </head> 
 <body> 
  <div class="block"> 
   <div class="centered"> 
    <img src="https://www.java2s.com/style/demo/Google-Chrome.png" alt="" class="left"> 
    <h3>Lorem ipsum dolor sit amet, consectetur adipiscing elit. </h3> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials