#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Location
    Currently, California
    Posts
    3
    Rep Power
    0

    Question Centering a page in DIV


    I am a newbie - a pre-newbie even, just learning CSS. I am on an iMac running Mountain Lion OS X 10.8.4 and using Adobe Dreamweaver 6. I am following a tutorial (Dreamweaver CS6 for Dummies) and have been over this code many times entering and reentering it. I am trying to center content on a Web page but it just won't work. I can't see the mistake. Can someone please enlighten me?

    Here's the modified code (URLs removed) for the entire page:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>About the Band</title>
    <style type="text/css">
    #container {
    width: 960px;
    margin-right: auto;
    margin-left: auto;
    background-color: #221C08;
    color: #FFFFFF;
    text-decoration: none;
    font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
    }
    ##text {
    padding-right: 15px;
    padding-left: 15px;
    }
    </style>
    </head>
    <link href="style.css" rel="stylesheet" type="text/css" />
    <body bgcolor="#221C08">
    <div id="container">
    <p align="center"><img src="images/bensbandlogo.jpg" width="601" height="119" alt="logo" /></p>
    <p align="center"><img src="images/bensolo.jpg" width="200" height="156" alt="ben" /></p>
    <div id="#text">
    <p align="justify">One of the Cincinnati area's fastest growing groups, The Ben Peterson Band is a great little band with a big sound that can accomodate just about everybody's musical tastes. From James Taylor to Janes Addiction, from Led Zeppelin and Johnny Cash to Cage the Elephant and Sublime. Whatever your live entertainment needs we will be happy to oblige.Intimate acoustic guitar settings to the big stage and lights of a full band! You and your friends are sure to be singing along and dancing all night long!!!</p>
    </div>
    <p align="center">&nbsp;</p>
    <p align="center">&nbsp;</p>
    <p align="center">&nbsp;</p>
    <div align="center"><a href="index.html" font-size: 15px; text-decoration: none;"> Return to Home Page</a></div>
    </div>
    </body>
    </html>
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2009
    Location
    Nebraska, USA
    Posts
    875
    Rep Power
    276
    Only thing I see is that you didn't close out your <head> tag before your <body> tag starts. Other than that, I don't see anything "popping out" at me saying "this is wrong".
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Location
    Currently, California
    Posts
    3
    Rep Power
    0
    Originally Posted by DonR
    Only thing I see is that you didn't close out your <head> tag before your <body> tag starts. Other than that, I don't see anything "popping out" at me saying "this is wrong".
    Thanks for your reply. I typed in </head> and refreshed and that made no difference. I am dumbfounded.
  6. #4
  7. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,129
    Rep Power
    4304
    Welcome to DevShed Forums, PhotoDon.

    What exactly are you trying to center? That code will center the "#container" element within the <body>. If you're trying to center something else within "#container", you'll need more/other styles.

    The <link> element should come after that <meta> element, not before the <head> tag.

    Which doctype are you using? Please post it with only the "http://www.w3.org" part of the URL removed.

    P.S. As you found out new users are restricted from posting URLs until they have made 5 posts. You may need to get around this by leaving out the "http://" and putting a space before each ".". Yes this rule is annoying, but the administrators say it's necessary for limiting spam.
    Spreading knowledge, one newbie at a time.

    Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Location
    Currently, California
    Posts
    3
    Rep Power
    0
    I made the changes you suggested and posted them over the original. Also, I had made changes to the code to "force" the page to center content as I wanted it. I'm sure the code is not a thing of beauty but it seems to look OK at least here on my computer.

    Also removed one of the double hash marks by ##text.

    Thanks for your reply.

    You can see the Web site by typing benpetersonband .com into your browser.

    Don

IMN logo majestic logo threadwatch logo seochat tools logo