8 Replies - 652 Views - Last Post: 24 October 2011 - 01:15 PM

#1 VolcomMky   User is offline

  • D.I.C Regular

Reputation: 74
  • View blog
  • Posts: 315
  • Joined: 13-May 09

CSS vs CENTER

Posted 24 October 2011 - 11:24 AM

Can somebody please tell me why the
<center>
is so hated?

Is it because its old school?
Is it because it isn't color coded pink in Dreamweaver?

Does it not work or center content?

What would be harder to use...

<center>Im in the middle.</center>

or
<div style="margin-left:auto; margin-right: auto; width:200px">Im in the middle too.</div>


Someone please make me understand why the codes that started it all will "ruin your website" and to "never use these tags"

Thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: CSS vs CENTER

#2 Ryano121   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1461
  • View blog
  • Posts: 3,289
  • Joined: 30-January 11

Re: CSS vs CENTER

Posted 24 October 2011 - 11:31 AM

For many reasons. In my opinion its because HTML should only deal with the the structural semantics and actual content of the webpage. All things to do with presentation belong to CSS. When you start to confuse the two, and add presentational elements to HTML, the code can quickly get very hard to maintain and follow. Developers look into a CSS file for information on the presentation of the webpage. The CSS file gives them all of this information. It is pointless to surf through the content of the page when looking for details on layout.

To reiterate maintainability, imagine if you had hundreds of center tags on your page, and then your boss came along and said "Well I actually want it all on the left hand side". You as the developer would have to comb through all of the center tags and change them. By putting this into a CSS file and by using a DIV, you have to change one class/id in the CSS file and the task is done.

This post has been edited by Ryano121: 24 October 2011 - 11:34 AM

Was This Post Helpful? 3
  • +
  • -

#3 Jstall   User is offline

  • Lurker
  • member icon

Reputation: 434
  • View blog
  • Posts: 1,042
  • Joined: 08-March 09

Re: CSS vs CENTER

Posted 24 October 2011 - 11:40 AM

It should also be noted that <center> is deprecated, you should avoid using deprecated tags.
Was This Post Helpful? 1
  • +
  • -

#4 EnvXOwner   User is offline

  • D.I.C Lover
  • member icon

Reputation: 358
  • View blog
  • Posts: 2,319
  • Joined: 10-August 09

Re: CSS vs CENTER

Posted 24 October 2011 - 12:32 PM

All styling should be done in CSS. That's it. The center tag as said above is deprecated. Also, I hope you do realize that most people don't use Dreamweaver, a lot of us actually discourage it for some shitty code it can produce. I know people who code in just Notepad on Windows and get no syntax highlighting. If you're centering text you use the text-align property of CSS. It would look something like this: text-align: center;. Also you don't need to do margin-left and margin-right auto, can just be margin: auto;. Also, inline styles are usually discouraged as well.
Was This Post Helpful? 0
  • +
  • -

#5 VolcomMky   User is offline

  • D.I.C Regular

Reputation: 74
  • View blog
  • Posts: 315
  • Joined: 13-May 09

Re: CSS vs CENTER

Posted 24 October 2011 - 01:00 PM

@EnvXOwner, I know, I was just using an example like when using a container.

@Ryano, I understand what your saying, but who would use hundreds?

Anything saying deprecated, I am going to ignore, not because your wrong but because I think its a stupid word.

So would you use the table tag because it is html to setup a layout?
Or stack about 20-100 div tags inside of each other?

When essentially, you can produce the same result with either one.

Also I don't think you can say because it will be hard to go through when looking into the code because I will tell you this, looking through a crap load of Div tags is no picnic either.
Was This Post Helpful? 0
  • +
  • -

#6 EnvXOwner   User is offline

  • D.I.C Lover
  • member icon

Reputation: 358
  • View blog
  • Posts: 2,319
  • Joined: 10-August 09

Re: CSS vs CENTER

Posted 24 October 2011 - 01:04 PM

No, using a table doesn't produce the same result. They're harder to manage and they load slower than when using a div. Looking through divs if you're good at documentation is rather easy. After the ending div I usually use a comment like so: <!-- /theclass --> So I know what class is being closed. Most of this information has been answered quite often on the Internet. I suggest doing a simple Google search on why you shouldn't use deprecated elements (it's not a stupid word) and why you shouldn't use tables for layout.
Was This Post Helpful? 0
  • +
  • -

#7 VolcomMky   User is offline

  • D.I.C Regular

Reputation: 74
  • View blog
  • Posts: 315
  • Joined: 13-May 09

Re: CSS vs CENTER

Posted 24 October 2011 - 01:08 PM

I have done the searches, but I wanted the opinion of those who maintain this website, not some person who writes what they think and says its correct.

Who here still uses the center tag and table tags?
I am not saying f*** div's, I am just voting that they are not gods gift to a website.
Was This Post Helpful? 0
  • +
  • -

#8 EnvXOwner   User is offline

  • D.I.C Lover
  • member icon

Reputation: 358
  • View blog
  • Posts: 2,319
  • Joined: 10-August 09

Re: CSS vs CENTER

Posted 24 October 2011 - 01:11 PM

I only use table tags for tabular data. I'm not really sure about your last sentence. To me, divisions in websites are probably some of the best things that have come to HTML, they allow you to style elements much easier than you could before.
Was This Post Helpful? 0
  • +
  • -

#9 Ryano121   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1461
  • View blog
  • Posts: 3,289
  • Joined: 30-January 11

Re: CSS vs CENTER

Posted 24 October 2011 - 01:15 PM

I think you are missing the point. Yes, nobody in the right mind would use hundreds of the tags, but that doesn't change the problem. You would still have to trawl through the content of the website to change the presentation, which makes no sense.

It's the same concept when using multiple files for your source code. Say we had all of our source code in one huge file. Most of the classes are completely unrelated, and perhaps aren't even used in this project. As a maintenance programmer, it's a pain in the ass to trawl through code that is completely unrelated to what you want to work with. Ultimately this takes more time and introduces mistakes.

Yes, looking through loads of Div tags can get a bit frustrated at times, but at least you are looking at the code that you actually want to see. If you are putting content in a webpage, you don't care about the CSS styling that goes behind the page. Perhaps someone else deals with that.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1