align text below an image in CSS - HTML CSS CSS Widget

HTML CSS examples for CSS Widget:Image Text Alignment

Description

align text below an image in CSS

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">
div.raspberry {<!-- ww  w.jav a 2  s  . co m-->
   float:left;
   margin:3px;
}

div p {
   text-align:center;
}
</style> 
 </head> 
 <body> 
  <div> 
   <div class="raspberry"> 
    <img src="https://www.java2s.com/style/demo/Firefox.png" width="100" height="100" alt="Screen 2"> 
    <p>Lorem ipsum<br>Lorem ipsu</p> 
   </div> 
   <div class="raspberry"> 
    <img src="https://www.java2s.com/style/demo/Firefox.png" width="100" height="100" alt="Screen 3"> 
    <p>Lorem ipsum<br>Lorem ipsu</p> 
   </div> 
   <div class="raspberry"> 
    <img src="https://www.java2s.com/style/demo/InternetExplorer.png" width="100" height="100" alt="Screen 3"> 
    <p>Lorem ipsum<br>Lorem ipsu</p> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials