0

I've been coding for about a 6 months now, and last week I saw a <center> tag for the first time. It seams to me that most of the time when people want content aligned to the center, they use:

<div align="center">

but this causes major issues when using

<style>
    position: absolute;
<style>

the center

<center> 

tag appears to work for position absolute, but since I've never seen it before, i'm wondering why it's not more popular and what it's cross-browser support is like. I don't overly wanna add this to my site if something like IE is just gonna outright reject it. I'm mainly just trying to understand the differences between the two so I can figure which i would like to use in my code.

Unmitigated
  • 76,500
  • 11
  • 62
  • 80
movie_nerd
  • 31
  • 5

2 Answers2

0

You will probably receive a few downvotes as the info is easily obtainable by using a google search and both methods you have selected are classed as obsolete.

The Center tag is an old obsolete tag which is no longer used. The align HTML attribute is also quite an old practice which was replaced with CSS.

I would recommend you look into CSS and class attributes, it gives a lot better control over the styling for modern websites.

ColinMD
  • 952
  • 6
  • 14
0

For an absolutely positioned element, you will need to set its width and use text-align: center to achieve the desired result.

.my-center{
  position: absolute;
  text-align: center;
  width: 100%;
}
<div class="my-center">
Center Aligned Text
</div>
Unmitigated
  • 76,500
  • 11
  • 62
  • 80