38 users online (0 members and 38 guests)  


  Results 1 to 7 of 7

Related

  1. Replies: 10
  2. Replies: 0
  3. Centered Pages?    Forum: HTML Forum
    Replies: 4
  4. Align text to Centered table    Forum: HTML Forum
    Replies: 6
  5. Having web content always centered    Forum: HTML Forum
    Replies: 3
  1. #1
    Lee's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2009
    Posts
    1

    Exclamation Content Stays Centered on web page.

    Hi, I know this must extremley easy and really stupid question.
    I am trying to build a web page where the content always stay centered no matter how you have your webbrower.
    I would like: blanck space/ then the content/blanck space. But the content is always to stay centered; here is an example of excatly what I want, just find the code that was used to make that happen. I use DreamWeaver CS3 by the way.
    Never mind wasnt able to post link.
    Question are:
    How to keep content centerd
    does each piece need to be its own table?
    Thank you
    Lee

  2. #2
    jthayne's Avatar

    Status
    Offline
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    508

    Re: Content Stays Centered on web page.

    Put the following in:
    Code:
    <body>
    <div align=center style="width:800px;">
    .......[content goes here]
    </div>
    </body>
    The opening and closing body tags are for reference only.

  3. #3
    rangana's Avatar
    Moderator/Allstar

    Status
    Offline
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    317

    Re: Content Stays Centered on web page.

    Do not use the align attribute, it is deprecated:
    http://www.w3.org/TR/REC-html40/index/attributes.html
    http://www.codehelp.co.uk/html/deprecated.html

    I suggest on using text-align property instead, and giving it a value of center:
    Code:
    <div style="text-align:center;width:800px;">
    .......[content goes here]
    </div>
    For further reading:
    http://www.w3schools.com/CSS/pr_text_text-align.asp

    Hope that helps.
    Last edited by rangana; 03-12-2009 at 01:29 AM. Reason: Give color to text-align
    Checkout my porfolio.
    Please click the button when a member helped you.
    Take time to use Forum's Search function.

  4. #4
    coothead's Avatar
    bald headed old fart

    Status
    Offline
    Join Date
    Aug 2003
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    732

    Re: Content Stays Centered on web page.

    Hi there Lee,

    and a warm welcome to these forums.

    I think that our friends jthayne and rangana have slightly misread your requirements.
    My guess is that you want something more along these lines...
    Code:
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta http-equiv="Content-Style-Type" content="text/css">
    
    <title></title>
    
    <style type="text/css">
    #container {
        width:760px;
        margin:auto;
        text-align:justify;
        background-color:#fee;
    }
    </style>
    
    </head>
    <body>
    
    <div id="container">
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Proin massa. Nam vehicula. 
    Morbi velit nisi, mollis id, ultrices luctus, adipiscing sit amet, lectus. Nunc rhoncus 
    nisl ac enim. Maecenas vestibulum dolor ut velit. Maecenas condimentum pulvinar purus. 
    Pellentesque ac ipsum. Curabitur sodales, elit vel molestie hendrerit, elit odio rhoncus tellus, 
    nec gravida enim urna id velit. Donec nec tellus. Vestibulum nulla. Curabitur enim arcu, 
    ornare id, placerat eget, nonummy vitae, mauris. Nulla rutrum semper odio. Duis vulputate 
    ornare mauris. Praesent eget nibh sed ante ultricies scelerisque. Duis eget felis ut arcu porta 
    bibendum. Mauris rutrum. Vivamus consectetuer purus sit amet mi. Suspendisse eu augue.
    </div>
    
    </body>
    </html>
    
    ...but, of course, I may be wrong.

  5. #5
    jthayne's Avatar

    Status
    Offline
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    508

    Re: Content Stays Centered on web page.

    You are right coothead. I had a brain lapse when writing my response. The margin: auto is the key.

  6. #6
    digitol's Avatar
    New User

    Status
    Offline
    Join Date
    Feb 2010
    Location
    Los Angeles, CA
    Posts
    1

    Re: Content Stays Centered on web page.

    COOTHEAD <3

    I have been trying to figure this out for ages. I beg many pardons to those on this site, but I am a visual artist through and thru, html was just something I picked up as a necessity. I have always wondered how to set these margins.

    I joined this site specifically just to thank you. You have no idea what this allows me to do

    Thank you very much!

    -Digitol

  7. #7
    coothead's Avatar
    bald headed old fart

    Status
    Offline
    Join Date
    Aug 2003
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    732

    Re: Content Stays Centered on web page.

    No problem digitol, you're very welcome.



Tags for this Thread