7

I found out a while back that the center tag was deprecated. Understandable because HTML is meant for structuring content and not so much for formatting. But why is the align attribute deprecated too? Attributes can be used for formatting. I understand that CSS can be used, but not everyone knows CSS. And to make it worse, text-align:center; and margin-left: auto; margin-right: auto; doesn't always center objects, but using pretty much always works.

Here's the Post from the W3C on this: http://www.w3.org/TR/html4/present/graphics.html#h-15.1.2

On a site I'm working with we are using the latest doctype (). Should I try my best not to use the align attribute? Is CSS the only safe way to center objects? I'm trying to make sure content is secure for the future.

Josh Lewis
  • 125
  • 1
  • 2
  • 9

1 Answers1

7

Yes, CSS should be used for that. I can't think of a single reason why it would be better to use an HTML attribute for alignment instead of a CSS rule. And if you don't want to learn CSS (which is fine), you might want to consider using a CSS framework like Twitter Bootstrap, especially the scaffolding part. It will save you a ton of time, make your site look good from the get go, and let you apply custom themes in a consistent fashion whenever you grow tired of the default one.

Ismael Ghalimi
  • 3,515
  • 2
  • 22
  • 25
  • 1
    Thank you for your swift response. I am pretty well rounded in CSS. But your average user is not. Some folks learn HTML just so that they can format their pages. But now that's being taken away to only those who want to seriously design web pages. Some sites don't even allow CSS inserted into content pages which will make alignment up to the webmaster to allow a class be used. In my case using the alignment is useful for things like adding a panorama at the top of my page. It is just as much work to place in a alignment attribute as placing in a class. Bootstrap is good from what I hear. – Josh Lewis Jan 27 '13 at 19:50
  • I think I get your point, but I don't think anything was taken away, because these HTML writers can still use HTML elements and attributes to format the page. The only difference is that instead of using standard elements or attributes that don't really belong to the HTML specification, they'll use CSS classes that you give them. They don't have to learn CSS itself though. All they have to do is to use the right classes. And using something like Twitter Bootstrap is a way to get lots of people using the same classes. It's not a standard per se, but it's a good starting point. – Ismael Ghalimi Jan 27 '13 at 19:53
  • I can give you a reason... True horizontal/vertical dynamic alignment(Left/Right/Center) on the screen or within a parent object... You can find a dozen+ solutions that claim to work but only about 2 out of 12 actually work and the CSS code looks ridiculous and typically requires header/trailer html objects to work correctly. Tables just worked when it came to alignment... They worked every time and every where and the script looked like far less of a work around than what most of the the CSS solutions show. – Tim Wiley Sep 17 '18 at 23:39