What is the best way to do this type of design?

Discussion in 'HTML & Website Design' started by Igozorus, Jul 9, 2013.

  1. #1
    Hello.I want to ask what is the best way to center all content.For example like this websites www.website.com www.burzum.org.
    Is the best way to do this is to create
    <div id="outer">
    <div id= "wraper">
    content
    </div>
    </div>
    and for css
    #wraper { 900px;margin:0px auto; }
    #outer { 960px;margin:0px auto; }

    So,wraper centers all the content,and outer does a margin for all content outside wraper so that design would look nicer.
    So,is it the only way to do this?And what about html5 where you don't use divs?
    Thank you
     
    Igozorus, Jul 9, 2013 IP
  2. WebDeveloperSahil

    WebDeveloperSahil Active Member

    Messages:
    331
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    80
    #2
    According to my opinion
    You don't need two wrappers, I always center my website by using single wrapper:
    <div id="outer">
    Centered content
    </div>

    CSS:
    #outer{margin: 0 auto; width:1024px;}

    This will center, but if you want to edit the background of wrapper then simply edit the body in CSS
    Like this:
    Write in CSS:
    body{background-color:grey;}
     
    Last edited: Jul 10, 2013
    WebDeveloperSahil, Jul 9, 2013 IP
  3. malky66

    malky66 Acclaimed Member

    Messages:
    3,997
    Likes Received:
    2,248
    Best Answers:
    88
    Trophy Points:
    515
    #3
    asking people to *like* your comment will get you instantly banned
    I suggest you read this:https://forums.digitalpoint.com/help/established
    especially the text in red.
     
    malky66, Jul 9, 2013 IP
  4. WebDeveloperSahil

    WebDeveloperSahil Active Member

    Messages:
    331
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    80
    #4
    Oppsie, my bad. Sorry for that, I didn't read that thread.
     
    WebDeveloperSahil, Jul 10, 2013 IP
  5. ekim941

    ekim941 Member

    Messages:
    74
    Likes Received:
    7
    Best Answers:
    7
    Trophy Points:
    33
    #5
    You don't really need an outer div. The standard way of centering content is with a wrapper div that has a width defined and set margin to 0 auto;
    <div id="wrapper">
    <p>Centered content goes here</p>
    </div>
    <style type="text/css">
    #wrapper{
    width:960px;
    margin:0 auto;
    }
    </style>
    HTML:
     
    ekim941, Jul 10, 2013 IP
  6. Igozorus

    Igozorus Greenhorn

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    6
    #6
    Yes,but if i do only one div-wrapper there will be no margin from the left.All the content-images,paragraphs,etc. will be without margin,it will not be centered it will be pushed to the left side
     
    Igozorus, Jul 10, 2013 IP
  7. Igozorus

    Igozorus Greenhorn

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    6
    #7
    Oh,and what about html5?Should i still use divs there?
     
    Igozorus, Jul 10, 2013 IP
  8. ekim941

    ekim941 Member

    Messages:
    74
    Likes Received:
    7
    Best Answers:
    7
    Trophy Points:
    33
    #8
    The wrapper div centers in the document window with margin set to auto. 0 defines top and bottom, auto defines left and right. It's just shorter than typing margin:0 auto 0 auto;

    For HTML5, you still use divs (often). HTML5 introduces new elements to make your documents more symantic (give the search engines more data about your data).
    You would still use a wrapper div to center your content.
     
    ekim941, Jul 10, 2013 IP
  9. xeod

    xeod Greenhorn

    Messages:
    47
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    23
    #9

    Oh well, that's why padding exists.Margins and paddings are the most used properties to space-out things on the page.As you could tell by now, margin is used for spacing outside of, lets say the div, but paddings on the other hand is used for spacing withing the current element ( div or tag, whatever you may wish )

    You can take a look here and get more familiar.
    http://codepen.io/anon/pen/bIGAv
     
    xeod, Jul 11, 2013 IP