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.
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>