How do I center a <div> tag?

Posted on 2008-11-18
Last Modified: 2013-11-19
On this page:

I want the two div boxes to be in the center of the page. How do I do this? Thanks, I'm new at using div tags.

<!--#include file="../../Connections/flagfootball.asp" -->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">

<html xmlns="">


<title>update news scroller</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><style type="text/css">


body {

	background-color: #999999;

	text-align: center;


.updatetext {

	background-color: #FFFFFF;

	height: 40px;

	width: 400px;

	vertical-align: top;

	text-align: center;

	margin-left: 0px;

	background-position: center;


.headerfooter {

	font-size: 12px;

	color: #000000;

	background-color: #FFFFFF;

	margin: 0px;

	padding: 0px;

	height: 25px;

	width: 400px;






  <div class="updatetext">  

    <h1>Update News Scroller<br />

      <br />



  <div class="headerfooter">

  The text that you type below will appear in the news scroller.


<form name="newsscroller" action="<%=MM_editAction%>" method="POST" id="newsscroller">

<div align="center">

	  <!-- Gets replaced with TinyMCE, remember HTML in a textarea should be encoded -->

	  <textarea id="elm1" name="elm1" rows="15" cols="80" style="width: 80%"><%=(rsnewsscroller.Fields.Item("newsscroll").Value)%></textarea>


    <br />

	  <input type="submit" name="save" value="Submit" />

	  <input type="reset" name="reset" value="Reset" />


<input type="hidden" name="MM_update" value="newsscroller" />

<input type="hidden" name="MM_recordId" value="<%= rsnewsscroller.Fields.Item("ID").Value %>" />




Open in new window

Question by:elliottbenzle
    LVL 3

    Expert Comment

    try <div align=center>
    LVL 15

    Accepted Solution


    body {
            background-color: #999999;
            text-align: center;
            margin: auto;
    LVL 9

    Expert Comment

    LVL 2

    Expert Comment

    width:set to the width of the 2 divs together
    margin:0 auto;
    div1, div2 {
    width: half of the container

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    Keeping 9 59
    Create associate webpages / websites 3 37
    Hand when hover boostrap carrousel 6 15
    Newbie CSS questions 4 14
    CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
    Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
    In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
    The viewer will learn how to count occurrences of each item in an array.

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now