Jump to content

Recommended Posts

Can someone tell me why the following code won't center the link

 


$msg = '<a href="http://www.gaf.com/General/GafMain.asp?Silo=RES1&WS=GAF&App=ROOF&Force=shingle-lines.asp">
<font  "color="#000066" size="+3"><center>GAF-ELK Shingle Styles & Colors</center></font></a>';

You need to learn about the difference between Block and inline elements.  An anchor is an inline element.  Hopefully this will help:  http://www.webdesignfromscratch.com/css-block-and-inline.cfm

 

Also the center tag is deprecated, meaning that you should be using css and not center.

 

 

an easy solution is this:

#This uses inline divs
$msg = '<div style="color:#000066;text-align:center;"><a href="http://www.gaf.com/General/GafMain.asp?Silo=RES1&WS=GAF&App=ROOF&Force=shingle-lines.asp">GAF-ELK Shingle Styles & Colors</a></div>';

 

It will make a new line for the link. I hope it helps, and please mark your topic as solved. W3Schools is a good place to learn css

Well, hopefully the main point is, that a link by itself is "inline".  In other words, it conforms to the flow of the "block" that contains it.  If that block element (a paragraph or div perhaps) is centered, then the link will be centered.  If it's a td in a table, ditto.  With that said, I hardily endorse not using the deprecated font and center tags, as this will fail standards validations and just make you look like a noob  ;)

yeah still new......the code provided in the above example didn't work either....I am inputing the data into this table:

 


<table>
  <td width="240" bgcolor="#CCCCCC"><p><a href="services.php"><font color="#9999FF" size="+3"><center>Services</font></a></p>
    <p><br />
          <br />
        </p>
    <p><a href="testimonials.php"><font style="vertical-align:top" color="#9999FF" size="+3">Testimonials</font></a></p>
    <p><br />
          <br />
        </p>
    <p><a href="resources.php"><font color="#9999FF" size="+3">Resources </font></a></p>
    <p><br />
          <br />
        </p>
    <p><a href="materials.php"><font color="#9999FF" size="+3">Materials</font></a></p>
    <p><br />
          <br />
        </p>
    <p><a href="insurance.php"><font color="#9999FF" size="+3">Insurance</font></a></p>
    <p><br />
          <br />
        </p>
    <p><a href="warranty.php"><font color="#9999FF" size="+3">Warranty</font></a></p>
    <p><br />
          <br />
        </p>
    <p><a href="contract.php"><font color="#9999FF" size="+3">Contract</center></font></a></p>
    <p><br />
    
        </p></td>
	<td align="left" valign="top"><font color="#006699"><?php echo "$msg"; ?></font></td>

</table>

 

and it still won't center no matter what I use to try to make it center.  Here is the original code again:

 


$msg = '<a href="http://www.gaf.com/General/GafMain.asp?Silo=RES1&WS=GAF&App=ROOF&Force=shingle-lines.asp">
<font  align="center" "color="#000066" size="+3">GAF-ELK Shingle Styles & Colors</font></a>';


This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.