WordPress.org

Ready to get started?Download WordPress

Forums

table cell text alignment (7 posts)

  1. plewis22
    Member
    Posted 2 years ago #

    I'm trying to center-align text in table cells, and align="center" only seems to work in a <p> tag, which adds an extra line that I don't want. I've tried putting it in <span> tags instead, or in the table tags, and it just doesn't take; the text is still left-aligned. Has anyone else had this problem?

    This is in (a child theme) of twenty eleven, if it matters.

  2. WPyogi
    Volunteer Moderator
    Posted 2 years ago #

    You need to use table styles -- for cells, they have to be assigned to the td tags. See this for more details:

    http://www.w3schools.com/css/css_table.asp

  3. plewis22
    Member
    Posted 2 years ago #

    Thanks but I think I'm doing that. Doesn't work in CSS and doesn't even work in in-line HTML. If I write <td align="center">content</td> then the content is still left-aligned. Is there something wrong with that syntax?

  4. WPyogi
    Volunteer Moderator
    Posted 2 years ago #

    Yes read the page linked to.

  5. plewis22
    Member
    Posted 2 years ago #

    OK, so if I put

    td, th { text-align: center }

    in the CSS file, that seems to work. But <td text-align="center"> in the post itself still has no effect. And I need to have some cells left-aligned and others center-aligned, so just one global setting isn't enough. Any idea what's going on?

  6. plewis22
    Member
    Posted 2 years ago #

    Ah ok, got it:

    <td style="text-align:left">

    thanks!

  7. Alex_Azov
    Member
    Posted 1 year ago #

    Works for me: <td style="text-align:left">
    Thanks!!!

Topic Closed

This topic has been closed to new replies.

About this Topic