Align text to the middle of it's box border - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Text

Description

Align text to the middle of it's box border

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">
.container {<!--  w ww. j a  va 2 s  .com-->
   margin:11px 51px;
}
</style> 
 </head> 
 <body>
   Problem: 
  <div class="container" style="text-align: center;"> 
   <div>
     Text 
   </div> 
   <div style="border-left: 1px solid #000; width: 1px; margin-left: auto; margin-right: auto;">
     &nbsp; 
   </div> 
   <div>
     Longer text 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials