<!DOCTYPE html> <html> <head> <meta charset = "utf-8"> <title>Centering</title> <style> div { border-style: solid; border-width: thin; border-color: blue; padding: .5ex; margin: 1em; font-size: x-large; } /* centered using margin auto note: the width must also be specified */ .center { width: 25%; margin: auto; } /* centered using left hand margin */ .center1 { width: 50%; margin-left: 25%; } .textcenter { text-align: center; } </style> </head> <body> <div class="center"> Here is some text that goes in a centered div </div> <div class="center1"> Here is another div, also centered </div> <div class="center1 textcenter"> One more centered div<br>with the contained text also centered </div> </body> </html> <!-- ************************************************************************** * (C) Copyright 1992-2012 by Deitel & Associates, Inc. and * * Pearson Education, Inc. All Rights Reserved. * * * * DISCLAIMER: The authors and publisher of this book have used their * * best efforts in preparing the book. These efforts include the * * development, research, and testing of the theories and programs * * to determine their effectiveness. The authors and publisher make * * no warranty of any kind, expressed or implied, with regard to these * * programs or to the documentation contained in these books. The authors * * and publisher shall not be liable in any event for incidental or * * consequential damages in connection with, or arising out of, the * * furnishing, performance, or use of these programs. * ************************************************************************** -->