www.webdeveloper.com
Results 1 to 7 of 7

Thread: can't center anchor tag in table

  1. #1
    Join Date
    Mar 2003
    Posts
    191

    can't center anchor tag in table

    I have a class called Essay that centers a table:

    table.Essay
    {
    margin-left:9%;
    margin-right:9%;
    }

    One of the td's is a link.I am trying to center this, but it won't center. I have:

    .Essay a
    {
    color: #000000;
    font-size: 16px;
    text-align: center;
    }

    .Essay a:link
    {
    color: #333333;
    }

    .Essay a:hover
    {
    color: #000066;
    }

    .Essay a:active
    {
    color: #000000;
    }

    .Essay a:visited
    {
    color: #333333;
    }

    I don't want to use:

    .Essay td
    {
    text-align: center;}

    as it would center all the other table data - i just want the link centered. What am i doing wrong?

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Put the text-align: center in .Essay a:link

  3. #3
    Join Date
    Mar 2003
    Posts
    191
    that doesn't work either.


  4. #4
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Try:
    .Essay td a:link
    {
    display: block;
    color: #333333;
    text-align: center;
    }

  5. #5
    Join Date
    Mar 2003
    Posts
    191
    that doesn't work either.


  6. #6
    Join Date
    Mar 2003
    Posts
    191
    hmm not sure where the above post came from, must've refreshed the page or something.

    but yes fang thats got it working, thanks for your help

  7. #7
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    <head>
    <title>center link in table</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <style type="text/css">
    <!-- 
    table.Essay 
    { 
    margin-left:9%; 
    margin-right:9%; 
    } 
    .Essay a 
    { 
    color: #000000; 
    font-size: 16px; 
    } 
    .Essay a:link 
    { 
    display: block;
    color: #333333; 
    text-align: center; 
    } 
    .Essay a:hover 
    { 
    color: #000066; 
    } 
    .Essay a:active 
    { 
    color: #000000; 
    } 
    .Essay a:visited 
    { 
    color: #333333; 
    } 
    -->
    </style>
    
    </head>
    <body>
    <table class="Essay" border="1" cellpadding="0" cellspacing="0" summary="">
    <tr><td><a href="http://www.mysite.com">apple</a></td></tr>
    <tr><td>banana</td></tr>
    <tr><td>cranberry</td></tr>
    </table>
    </body>
    </html>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles