/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] alternate to center

I read that you’re supposed to replace <center> with <div style=”text-align:center”>. However, this

[code=html]<div style=’text-align:center’>
<table border=’1′><tr><th colspan=’3′>Hello World</th></tr>
<tr><th>Col1</th><th>Col2</th><th>Col3</th></tr></table>
</div>[/code]

does not center the table. I have this CSS applied to it:

[code]body {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
text-align: center;
margin-left: 5px;
margin-bottom: 5px;
margin-right: 5px;
margin-top: 5px;
}
table, tr, td, th {
text-align: center;
margin-bottom: 0px;
margin-left: 0px;
margin-right: 0px;
margin-top: 0px;
table-layout: fixed;
}[/code]

What should I do??? ?

[color=white].[/color]

to post a comment
CSS

2 Comments(s)

Copy linkTweet thisAlerts:
@ray326Jul 31.2006 — That rule only applies to text within the div. Only the idiot IE browser will center block elements like tables when that's applied. To center a block element,

  • 1. set its width narrower than its container

  • 2. apply [B]text-align:center[/B] to the element's [B]container[/B]

  • 3. apply [B]margin:0 auto[/B] to the [B]element[/B] you want centered
  • Copy linkTweet thisAlerts:
    @shane_carrauthorJul 31.2006 — It works! Thanks! ?
    ×

    Success!

    Help @shane_carr spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 6.16,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @nearjob,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,
    )...