CSS alternative to 'center' tag
8 posts
• Page 1 of 1
CSS alternative to 'center' tag
Since I started using CSS over the old school 'style' tags (ie 'font'), I 've never been able to find a very good replacement of the 'center' tag. I still use it, but I would prefer if an alternative could be found...
... you know, just to be pure.
Mac OS 10.6.7 - Personal
Ubuntu Server 11.04 - Server
Re: CSS alternative to 'center' tag
gries818 wrote:Since I started using CSS over the old school 'style' tags (ie 'font'), I 've never been able to find a very good replacement of the 'center' tag. I still use it, but I would prefer if an alternative could be found...
... you know, just to be pure.
[ below is equal to <
- Code: Select all
[div style="margin:0 auto"]your content here[/div]
Of course a div tag by default is 100% wide, so if you want it centered, you'll also need to specify a "width:123px" for the div or p itself.
You can also use "text-align:center" to center text within a div or p tag. And worst case, just do
- Code: Select all
[div align="center"]
This won't work on the span tag, since it's an inline tag. You'd have to make it a block tag for it to work on that.
"Greatness is not a function of circumstance. Greatness, it turns out, is largely a matter of conscious choice, and discipline." - Jim Collins
- kanaloa
- President
- Posts: 11795
- Joined: Sun Mar 10, 2002 1:18 am
- Location: HI & SC
- Real Name: John Derrick
Re: CSS alternative to 'center' tag
kanaloa wrote:gries818 wrote:Since I started using CSS over the old school 'style' tags (ie 'font'), I 've never been able to find a very good replacement of the 'center' tag. I still use it, but I would prefer if an alternative could be found...
... you know, just to be pure.
[ below is equal to <
- Code: Select all
[div style="margin:0 auto"]your content here[/div]
Of course a div tag by default is 100% wide, so if you want it centered, you'll also need to specify a "width:123px" for the div or p itself.
You can also use "text-align:center" to center text within a div or p tag. And worst case, just do
- Code: Select all
[div align="center"]
This won't work on the span tag, since it's an inline tag. You'd have to make it a block tag for it to work on that.
This trick doesn't seem to work in Safari. Any idea why?
And the center tag doesn't center within a div like Firefox does. WTF Apple
Mac OS 10.6.7 - Personal
Ubuntu Server 11.04 - Server
Re: CSS alternative to 'center' tag
That's why I only worry about FF and IE (and I wish I didn't have to bother with the later, though at least they are making progress - I just wish they'd 'force' upgrades like FF does).
"Greatness is not a function of circumstance. Greatness, it turns out, is largely a matter of conscious choice, and discipline." - Jim Collins
- kanaloa
- President
- Posts: 11795
- Joined: Sun Mar 10, 2002 1:18 am
- Location: HI & SC
- Real Name: John Derrick
Re: CSS alternative to 'center' tag
kanaloa wrote:That's why I only worry about FF and IE (and I wish I didn't have to bother with the later, though at least they are making progress - I just wish they'd 'force' upgrades like FF does).
Hmm, well since I use Safari as my main browser, I'd kind of like to write sites that work just as well with it as in Firefox.
The problem appears to be that Safari treats the center tag as the center of the page, and not the center of an element like Firefox and IE. I'm sure there is a way around this... I never have problems out on the web with Safari.
I'll post when I figure it out
Mac OS 10.6.7 - Personal
Ubuntu Server 11.04 - Server
Re: CSS alternative to 'center' tag
Crazily, text-align:center seems to accomplish the task on both browsers.
Mac OS 10.6.7 - Personal
Ubuntu Server 11.04 - Server
Re: CSS alternative to 'center' tag
gries818 wrote:Crazily, text-align:center seems to accomplish the task on both browsers.
Hopefully the next version of CSS will get a lot of these "interesting" issues fixed.
"Greatness is not a function of circumstance. Greatness, it turns out, is largely a matter of conscious choice, and discipline." - Jim Collins
- kanaloa
- President
- Posts: 11795
- Joined: Sun Mar 10, 2002 1:18 am
- Location: HI & SC
- Real Name: John Derrick
Re: CSS alternative to 'center' tag
kanaloa wrote:gries818 wrote:Crazily, text-align:center seems to accomplish the task on both browsers.
Hopefully the next version of CSS will get a lot of these "interesting" issues fixed.
The really interesting part is that the text-align:center works on one of my divs, but not another
But at least it isn't working in both Safari and Firefox... hopefully it is for the same reason.
Mac OS 10.6.7 - Personal
Ubuntu Server 11.04 - Server
8 posts
• Page 1 of 1
Return to HTML, CSS, and Scripts
Who is online
Users browsing this forum: No registered users and 2 guests