Can someone actually explain why the <center> tag is deprecated?


#21

Well, I for one am quite confident that optl has a firm grasp on what will save him time and won't.
He asked why the tag was deprecated, and buried within the whirlwind of non-issues thrown at him is an actual answer. And that answer is not "Because the hyper web l33t decided". Who cares? I want to know why they decided and why using this tag is not a good idea. Reminds me of Richard Feynman discussing his Nobel prize - "I don't like accolades, they are a joke. I mean who is this Alfred Nobel and why is he giving away prizes?"

We need to know why semantic markup is important TO US.
Why is the holy grail of separation more than just some pie in the sky dream of the l33ters? Why is it actually important for those "fighting in the trenches"?


#22

Thanks for the support man. People seem to have deviated from the original question just so they can make me look bad. I hope that's not the case. Let's get this thread back on track.

I, too, would like to know why the separating structure and style is so important to us.


#23

I already gave an example earlier in this thread.

If you have thousands of pages on your web site and want to make a small change to the appearance (such as left justifying elements that were centered) then with CSS you take two seconds to update the CSS entry that all those elements share that determines their position. With the appearance defined in the HTML you spend a month or three going through changing each page separately and hope you don't miss any.

Updates to your CSS can change the appearance of all your web pages all at once whereas if the appearance is defined in the HTML then each and every page needs to be updated separately.

Another example would be if you had a three column layout where instead of 123 you wanted to reorder the columns to 213. Again two seconds of changes to the CSS and you're done compared to making really massive changes to the HTML.

Another completely different reason for separating them is when you have a different appearance needed for print and spoken versions of the page to what you have on the screen. That separation can only be done with CSS. Any presentational elements in the web page are garbage as far as web readers are concerned as they need to know what voice to use to speak the text and not what font or alignment to use.


#24

Keeping your style separate let's you
a) achieve a level of congruity and eases maintenance sitewide. If you have an area that should be identical across many pages, separated style lets you build it once, and use it over and over. If you want to change it, you change it in one place instead of across every page.
b) does make for lighter weight pages. Less nasty code on a page for you to have to pour through. Easier on your brain, faster for your users.
c) client computer loads your external stylesheet one time and your content just uses that.

CSS has a great deal in common with the more object oriented languages I think. You have all the cool inheritance, lots of the abstraction and...I can't remember the official name, but compartmentalization of say a Java or a C. Encourages and allows reuse.
I personally think that perhaps it's best effect on me is one I don't generally think about. It encourages me to view things in a modular sense. I'm very used to block structure in my visual design, but separation encourages me to treat my code in much the same manner. CSS lets me build a style one time and use it over and over.

Behavior - much the same thing. Your html page contains only text and lightweight pointers to your style and behavior mechanisms.

When it comes maintenance time, you notice that the little quote box that you use on 100 pages is not just right. You only have to go to your stylesheet and adjust your quote box "object" definition. Now those 100 pages are maintained, and you only needed to fix a couple lines in one file instead of doing some awful sitewide find and replace.

You notice that your function that gets called when you click a button (that you have on 25 pages) isn't doing what you want. All of those buttons call the exact same function that you cleverly defined in one external behavior file and your pages all use. You fix that one file, all 25 pages get maintained.

Separation encourages us and allows us to bring an object oriented style of discipline to something often approached monolithically.

I'm really wary though, I take everything with a grain of salt. Object orientation is not the new fancy thing it's touted as. It's just sensible in many cases, and it's been around since the dawn of computers. We just moved it from the level of instinct into our conscious minds. And even that was done in the very early 70s first. Here we are 40 years later and we are arrogant enough to regard it as some pinnacle.
It's kinda like "just in time" inventory control. It's just a fancy name for "don't buy things until you need them". An idea that probably occurred to some factory owner about 2 years after the start of the industrial revolution. He was probably beating his 8 year old orphan coal shoveler at the time.

I promised to watch my ranting, I think I might have fell short this time!


#25

Which is semi-true if that's the ONLY markup on the page, but being that 'download file' is probably part of a larger section of markup, you probably already have a grouping div around all of it, and you have a perfectly good anchor right there ANYWAYS.

<a href="#" class="downloadLink">Download File</a>

or

<div class="download">
	<h2>Download Name</h2>
	<img src="images/screencap.png" alt="screencap of download in action />
	<p>
		Description of download
	</p>
	<a href="downloads/whatever.rar">Download File</a>
</div>

Which in the CSS you'd target as ".download a" - using that there's only one anchor so you don't need a class except that off it's parent - which you would also use to target the H2, IMG and P.

In either case, you're not even making extra tags, you're just adding a class to the parent or to an already existing element. Also gives you the hooks to change the font size, the colors, the font-weight, should you decide you want that too.

... and again, say what it is, the anchor for the download, and not how it appears. The big question you should always be asking yourself in your markup is what is it, and WHY am I applying presentation to it?


#26

I wouldn't say that's what people have done in this thread.

I simply haven't had a need for a <center> tag or a presentational class like 'centerme' ever. As Tommy illustrated there is usually markup that allows you to only add contextual css to achieve centering which is far less typing if you use it more than once.

It's not that they're trying to make you look bad, they've been at it a very long time and know what to avoid.


#27

optl, I see your point that <center></center> is less work than writing up the equivalent in css CSS:

<center><h1>My nice centered title</h1></center>

(17 characters, simple code) is less than (22+ characters, more complex code)

h1 { text-align:center; }

But as soon as you have to do this to 3 pages it loses the whole concept of it being "less work" doesn't it? And I'm not even taking into account changing things into the future.

As for screen readers, I haven't used one in a while but I think in terms of that it would make sense that they would completely ignore the center tag element so there should be no problem there.

Otherwise I tend to agree, it's deprecated because it's a style element rather than a descriptive one and that simply doesn't belong in html.


#28

Well, the reason CENTER is deprecated in strict document types is simply that it is presentational, and presentational tags were removed from STRICT doctypes. That is just a fact.

It was done because the designers of html decided that presentational tags in html are a bad thing. Now if you want to argue in favour of presentational tags in strict doctypes feel free. But it has nothing to do with "why" CENTER is deprecated.


#29

It isn't just a fact as there was a very good reason why it was done. Separating out the presentation makes it a lot easier to apply different presentation to different media and also makes changing the presentation much easier.

Getting rid of the presentation from HTML and applying it separately via CSS can reduce months of work down to a few minutes on large web sites and results in significant time saving even on smaller web sites.


#30

Yes is shorter. If it is for just that one instance, your fingers would actually type fewer characters than if you were to do it with CSS. Yes, it is shorter. You are right. Good luck.


#31

Thank you. That's all I was trying to say. I would never use <center> in any real life situation for reasons stated by others in this thread.


#32

Just a fact. :nono:

:forehead slap:
:rolled eyes:
:exasperated groan:


#33

You made me think for a second that I'd be doing CSS centering the hard way for all these years, but my suspicions of your example were correct. "align" is not a valid CSS property.


#34

Right. Now show me were a difference of 31 bytes would make a noticeable increase in page load speed.

If you have a billion visitors a day, I can understand that saving 31 bytes per visit (31 GB/day) could make a difference in cost. But the benefit to the visitors would be negligible.


#35

Of course if there are thousands of pages then the saving no longer exists and instead you have added a huge amount to the cost of mainitaining the site. You'd only get that saving with a one page site and billions of visitors a day.


#36

The <center> HTML/xHTML tag

The <center> tag is used to align content in the centre of it’s parent element..

<snip/>


#37

Wow, how ridiculous and utterly pointless has this discussion become?

It's not hard to see the benefits of separating concerns. That's why it's so popular in the programming world. Unfortunately, the current HTML, CSS and JavaScript technology stack doesn't do a very good job of separating concerns, although it tries hard. I'd say that this is the main reason why tags such as <center> and <b> have been deprecated. If it can be done with a stylesheet, then the same functionality/capability SHOULDN'T also exist in HTML.

But besides the advantages of separating concerns, and the fact that the tag has been deprecated, the other reasons not to use it have already been peppered throughout this article. By keeping all visual mark-up in stylesheets, maintenance becomes easier and bandwidth is saved.

If you have a single page site, and couldn't give a crap about the fact that the center tag is deprecated, then why not use it. After all, you'll save a few seconds which you can put to good use, such as sleeping.


#38

FWIW, <b> is not deprecated. It's still allowed if you want to adhere to some typographic convention for which there is no semantically appropriate element type.

Or learning proper web developement … stuck_out_tongue


#39

I certainly agree the reasons were good. Very good indeed.

But that's beside the point if we ask only the narrow question of "why" the CENTER tag is deprecated, which is what the OP titled this thread.


#40

O key, Dear

The <center> tag has also been used to center tables and other structures within the page, not just text. This use of tables is also now deprecated. Tables are to be reserved for tabular data - for those situations where two or more columns and two or more rows of data need to be displayed in a grid. The days of using a single cell table with hidden borders to position text within the page have gone. Generally, as on this page, for a table to be required the content should demand to be divided into visible columns and visible rows.

<snip/>