1

What is the significant differences between using CSS to center something on a page, rather than the tags?

Will affect page layout, compatibility etc?

Much Thanks.

sirnomnomz
  • 623
  • 1
  • 7
  • 20
  • 1
    Using CSS separates the look and feel of a page from the html. Then you can easily swap CSS files to completely change how a web page looks, without having to dig through the html. – forgivenson Apr 02 '14 at 14:37
  • There isn't much point in asking about a deprecated tag, it was deprecated for a reason: you're not supposed to use it anymore. – cimmanon Apr 02 '14 at 14:45
  • I agree with my colleagues. `
    ` is deprecated and you shouldn't use it, however, that doesn't necessarily mean that you CAN'T use it. Browsers still will render it. And if you are maintaining an old site, such as the one I am dealing with now which it needs to run in Quirksmode (grrrrr) you will see a lot of center tags and sometimes is not cost effective to change every center tag in thousands of pages.
    – LOTUSMS Apr 02 '14 at 14:51
  • Now, to answer your question. When you use the p tag and then use `text-align:center` you still have to deal with the properties that are attached to the p tag. Whether they are being declared by you or not, the browser has its own defaults that apply to `

    ` However, the `

    ` tag is very raw and clear of browser properties See the [DEMO](http://codepen.io/anon/pen/xawfq/) to see the difference from both uses
    – LOTUSMS Apr 02 '14 at 14:52

3 Answers3

5

The <center> tag has been deprecated in HTML4 (and XHTML1) in favor of the CSS text-align property, which can be applied to the <div> element or to an individual <p>.

For more info: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/center

It is always better to separate the "code" (HTML) and the styles (CSS), so in any case, CSS is the way to go.

Andrew
  • 2,013
  • 1
  • 23
  • 38
Rafa Romero
  • 2,667
  • 5
  • 25
  • 51
0

To be short, just don't use center tag. Let it go into oblivion together with marquee.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/center

keaukraine
  • 5,315
  • 29
  • 54
0

<center> is an HTML tag, which is now depreciated

It's beter to use CSS prepriety instead: it's because it's better to isolate the structure (HTML) and design (CSS)

Gwenc37
  • 2,064
  • 7
  • 18
  • 22