SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Wizard holmescreek's Avatar
    Join Date
    Mar 2001
    Location
    Northwest Florida
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Using <center> tag & CSS ?

    I've seen several people ask about centering their layout in css. I'm curious, why couldn't you just put <center> tag after the body, but before the main wrapper? Then in the main wrapper use text-align:left ?

    It seems to work fine, just curious why this isn't commonly used?
    intragenesis, llc professional web & graphic design

  2. #2
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,476
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As all4nerds said, <center> has been depreciated in HTML 4 due to being a presentational markup element. Presentational markup has been earmarked for removal by the specification in favor of structural HTML markup, thereby letting the stylesheet (CSS document in this case) handle the presentation.

  3. #3
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by holmescreek View Post
    why couldn't you just put <center> tag after the body, but before the main wrapper?
    You could, but it wouldn't be a very clever thing to do. What if you decide next year that the site should not be centred, but be left-aligned instead? If you use CSS only, it's a matter of changing one rule in one CSS file, and it's done. If you use the deprecated CENTER element, you'll have to edit each and every HTML file on the site.

    That is one of the reasons why presentational markup is a bad thing.
    Birnam wood is come to Dunsinane

  4. #4
    Non-Member deathshadow's Avatar
    Join Date
    Jul 2006
    Location
    Dublin, NH
    Posts
    901
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AutisticCuckoo View Post
    If you use the deprecated CENTER element, you'll have to edit each and every HTML file on the site.
    Which is probably why that arguement (both in this case and against tables) holds less weight with me - since I tend to only write CMS these days - or at bare minimum use DHTML, PHP, Cold fusion, or some other SSI/CGI to make all my pages share the same html formatting.

    BUT, for me, If I want to center the whole thing, I just put the margins and width in the body tag. Doesn't work in IE 5.x (oh noes! Like I give a **** at this point) ... Putting it into the CSS instead of in the HTML has one other advantage - one that I pay a LOT more attention too.

    It's less bandwidth used - shared CSS is cached between multiple pages, HTML is not. The more you can put into the CSS, the less the client has to load on each page AFTER the first.

  5. #5
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by deathshadow View Post
    Which is probably why that arguement (both in this case and against tables) holds less weight with me - since I tend to only write CMS these days - or at bare minimum use DHTML, PHP, Cold fusion, or some other SSI/CGI to make all my pages share the same html formatting.
    So that makes you have to edit in fewer places (maybe only one if you have a simple site with just one template, or use a template hierarchy). But the pages still need to be served anew, putting unnecessary load on your server, using up bandwidth, and forcing your visitors to wait for a new page instead of using their cached versions.
    Birnam wood is come to Dunsinane

  6. #6
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,556
    Mentioned
    183 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by tommy
    If you use the deprecated CENTER element, you'll have to edit each and every HTML file on the site.

    No.... CSS to the rescue again
    Code:
    center {text-align:left}
    I have been drinking though

  7. #7
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Lol
    Birnam wood is come to Dunsinane

  8. #8
    SitePoint Wizard holmescreek's Avatar
    Join Date
    Mar 2001
    Location
    Northwest Florida
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AutisticCuckoo View Post
    You could, but it wouldn't be a very clever thing to do. What if you decide next year that the site should not be centred, but be left-aligned instead?
    In that case, I actually use DW templates and would only have to make a change to the master template and all pages are updated. But, that aside, I finally found a good book on CSS and now understand where everyone is coming from.

    Thanks everyone for all the replies and advice.
    intragenesis, llc professional web & graphic design

  9. #9
    SitePoint Wizard holmescreek's Avatar
    Join Date
    Mar 2001
    Location
    Northwest Florida
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AutisticCuckoo View Post
    You could, but it wouldn't be a very clever thing to do. What if you decide next year that the site should not be centred, but be left-aligned instead?
    In that case, I actually use DW templates and would only have to make a change to the master template and all pages are updated. But, that aside, I finally found a good book on CSS and now understand where everyone is coming from.

    Thanks everyone for all the replies and advice.
    intragenesis, llc professional web & graphic design

  10. #10
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,556
    Mentioned
    183 Post(s)
    Tagged
    6 Thread(s)
    In that case, I actually use DW templates and would only have to make a change to the master template and all pages are updated.
    Think ahead! Uploading a thousand altered pages can be a long and dangerous process

    Uploading one css file can take seconds.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •